awesome-wm-widgets/weather-widget/README.md

79 lines
2.4 KiB
Markdown
Raw Normal View History

2017-02-08 02:31:34 +01:00
# Weather widget
2019-01-29 21:55:56 +01:00
![Weather Widget](./weather-widget.png)
2017-02-08 02:31:34 +01:00
Note that widget uses the Arc icon theme, so it should be [installed](https://github.com/horst3180/arc-icon-theme#installation) first under **/usr/share/icons/Arc/** folder.
2019-05-05 03:03:13 +02:00
## Customization
It is possible to customize widget by providing a table with all or some of the following config parameters:
| Name | Default | Description |
|---|---|---|
| `font` | `Play 9` | Font |
| `city` | `Montreal,ca` | City name and country code, [more info](https://openweathermap.org/current) |
| `api_key` | none| API key, required |
| `units` | `metric` | `metric` for celsius, `imperial` for fahrenheit |
2019-08-27 07:28:43 +02:00
| `both_units_widget` | `false` | show temperature in both units (15°C (59°F)) or in one (15°C) |
| `both_units_popup` | `false` | same as above but for popup |
2019-05-05 03:03:13 +02:00
### Example:
```lua
weather_widget({
api_key = 'your-api-key',
units = 'imperial',
font = 'Ubuntu Mono 9'
}),
```
2017-02-08 02:31:34 +01:00
## Installation
2019-01-27 05:00:31 +01:00
1. Install lua socket - to make HTTP calls to get the weather information.
```bash
$ sudo apt-get install lua-socket
```
1. Download json parser for lua from [github.com/rxi/json.lua](https://github.com/rxi/json.lua) and place it under **~/.config/awesome/** (don't forget to star a repo <i class="fa fa-github-alt"></i> ):
```bash
wget -P ~/.config/awesome/ https://raw.githubusercontent.com/rxi/json.lua/master/json.lua
```
1. Clone this repo under **~/.config/awesome/**:
```bash
git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/
```
2019-05-05 03:03:13 +02:00
1. Get Open Weather Map app id here: [openweathermap.org/appid](https://openweathermap.org/appid).
2019-01-27 05:00:31 +01:00
1. Require weather widget at the beginning of **rc.lua**:
```lua
local weather_widget = require("awesome-wm-widgets.weather-widget.weather")
```
1. Add widget to the tasklist:
```lua
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
...
2019-05-05 03:03:13 +02:00
--default
weather_widget({api_key = 'your-api-key'}),
--customized
weather_widget({
api_key = 'your-api-key',
units = 'imperial',
font = 'Ubuntu Mono 9'
})
2019-01-27 05:00:31 +01:00
...
```
2017-02-08 02:31:34 +01:00
2017-02-13 02:58:50 +01:00
You can read how it works in more details [here](http://pavelmakhov.com/2017/02/weather-widget-for-awesome-wm)