Skip to content

Commit 09feeaa

Browse files
authored
Merge pull request #448 from Ryuno-Ki/weather-migration
feat: migrate weather.lua to use WeatherAPI
2 parents d646bb6 + d9e9ee6 commit 09feeaa

26 files changed

+556
-8
lines changed

apt-widget/apt-widget.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,6 @@ local apt_widget = wibox.widget({
6363
end,
6464
})
6565

66-
local apt_widget_button = wibox.widget({
67-
{
68-
apt_widget,
69-
widget = wibox.container.margin,
70-
},
71-
widget = clickable_container, -- luacheck: ignore (todo fix)
72-
})
73-
7466
--- Parses the line and creates the package table out of it
7567
--- yaru-theme-sound/focal-updates,focal-updates 20.04.10.1 all [upgradable from: 20.04.8]
7668
local parse_package = function(line)

weather-api-widget/README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# WeatherAPI widget
2+
3+
![Current Weather popup](./popup.png)
4+
5+
The widget consists of one section:
6+
- current weather, including humidity, wind speed, UV index
7+
8+
## Customization
9+
10+
It is possible to customize widget by providing a table with all or some of the
11+
following config parameters:
12+
13+
| Name | Default | Description |
14+
|---|---|---|
15+
| coordinates | Required | Table with two elements: latitude and longitude, e.g. `{46.204400, 6.143200}` |
16+
| api_key | Required | [Follow the documentation](https://www.weatherapi.com/docs/) |
17+
| font_name | `beautiful.font:gsub("%s%d+$", "")` | **Name** of the font to use e.g. 'Play' |
18+
| units | `metric` | `metric` for celsius, `imperial` for fahrenheit |
19+
| icon_pack_name | `weather-underground-icons` | Name of the icon pack, could be `weather-underground-icon` or `VitalyGorbachev` or create your own, more details below |
20+
| icons_extension | `.png` | File extension of icons in the pack |
21+
| timeout | 120 | How often in seconds the widget refreshes |
22+
23+
### Icons:
24+
25+
The widget comes with two predefined icon packs:
26+
27+
- [weather-underground-icons](https://github.com/manifestinteractive/weather-underground-icons)
28+
- [VitalyGorbachev](https://www.flaticon.com/authors/vitaly-gorbachev)
29+
30+
To add your custom icons, create a folder with the pack name under `/icons` and
31+
use the folder name in widget's config. There should be 18 icons, preferably
32+
128x128 minimum. Icons should also respect the naming convention, please check
33+
widget's source.
34+
35+
### Examples
36+
37+
#### Custom font, icons
38+
39+
```lua
40+
weather_api_widget({
41+
api_key='<your-key>',
42+
coordinates = {45.5017, -73.5673},
43+
units = 'imperial',
44+
font_name = 'Carter One',
45+
icons = 'VitalyGorbachev',
46+
icons_extension = '.svg',
47+
}),
48+
```
49+
50+
#### Only current weather
51+
52+
```lua
53+
weather_api_widget({
54+
api_key='<your-key>',
55+
coordinates = {45.5017, -73.5673},
56+
}),
57+
```
58+
59+
## Installation
60+
61+
1. Download json parser for lua from
62+
[github.com/rxi/json.lua](https://github.com/rxi/json.lua) and place it
63+
under **~/.config/awesome/**
64+
(don't forget to star a repo <i class="fa fa-github-alt"></i> ):
65+
66+
```bash
67+
wget -P ~/.config/awesome/ https://raw.githubusercontent.com/rxi/json.lua/master/json.lua
68+
```
69+
70+
1. Clone this repo under **~/.config/awesome/**:
71+
72+
```bash
73+
git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/
74+
```
75+
76+
1. [Get Weather API key](https://www.weatherapi.com/docs/).
77+
78+
1. Require weather widget at the beginning of **rc.lua**:
79+
80+
```lua
81+
local weather_api_widget = require("awesome-wm-widgets.weather-api-widget.weather")
82+
```
83+
84+
1. Add widget to the tasklist:
85+
86+
```lua
87+
s.mytasklist, -- Middle widget
88+
{ -- Right widgets
89+
layout = wibox.layout.fixed.horizontal,
90+
...
91+
--default
92+
weather_api_widget({
93+
api_key='<your-key>',
94+
coordinates = {45.5017, -73.5673},
95+
}),
96+
,
97+
--customized
98+
weather_api_widget({
99+
api_key='<your-key>',
100+
coordinates = {45.5017, -73.5673},
101+
units = 'imperial',
102+
font_name = 'Carter One',
103+
icons = 'VitalyGorbachev',
104+
icons_extension = '.svg',
105+
}),
106+
...
107+
```
108+
109+
## How it works
110+
111+
The widget calls the API repeatedly in the specified intervals. The JSON
112+
response is parsed and interpreted to build the popup.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)