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

148 lines
5.0 KiB
Markdown
Raw Normal View History

---
layout: page
---
# Weather widget
2020-11-15 03:26:34 +01:00
<p align="center">
<a href="https://github.com/streetturtle/awesome-wm-widgets/labels/weather" target="_blank"><img alt="GitHub issues by-label" src="https://img.shields.io/github/issues/streetturtle/awesome-wm-widgets/weather"></a>
<a href="https://twitter.com/intent/tweet?text=Check%20out%20this%20awesome%20weather%20widget%20for%20Awesome%20Window%20Manager%20&url=https://github.com/streetturtle/awesome-wm-widgets/blob/master/weather-widget" target="_blank">
<img alt="Twitter URL" src="https://img.shields.io/twitter/url?logo=twitter&style=social&url=https%3A%2F%2Fgithub.com%2Fstreetturtle%2Fawesome-wm-widgets%2Fblob%2Fmaster%2Fweather-widget">
</a>
</p>
2020-09-13 02:49:43 +02:00
2022-01-24 01:17:02 +01:00
The widget showing current, hourly and daily weather forecast:
2020-08-17 23:05:56 +02:00
2020-07-14 17:01:04 +02:00
<p align="center">
2020-11-15 03:26:34 +01:00
<img src="https://github.com/streetturtle/awesome-wm-widgets/raw/master/weather-widget/weather-widget.png" alt="screenshot" style="max-width:100%;">
2020-07-14 17:01:04 +02:00
</p>
2019-12-15 21:38:54 +01:00
2020-11-15 03:26:34 +01:00
The widget consists of three sections:
2020-07-14 17:01:04 +02:00
- current weather, including humidity, wind speed, UV index
- hourly forecast for the next 24 hours
- daily forecast for the next five days
2019-12-15 21:38:54 +01:00
## Customization
It is possible to customize widget by providing a table with all or some of the following config parameters:
| Name | Default | Description |
|---|---|---|
2020-07-14 17:01:04 +02:00
| coordinates | Required | Table with two elements: latitude and longitude, e.g. `{46.204400, 6.143200}` |
2020-11-15 03:26:34 +01:00
| api_key | Required | Get it [here](https://openweathermap.org/appid) |
2020-07-14 17:01:04 +02:00
| font_name | `beautiful.font:gsub("%s%d+$", "")` | **Name** of the font to use e.g. 'Play' |
| both_units_widget | false | Show temperature in both units - '28°C (83°F) |
| units | metric | `metric` for celsius, `imperial` for fahrenheit |
| show_hourly_forecast | false | Show hourly forecase section |
| time_format_12h |false | 12 or 24 hour format (13:00 - default or 1pm) |
| show_daily_forecast | false | Show daily forecast section |
| 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 |
2021-04-13 03:39:49 +02:00
| icons_extension | `.png` | File extension of icons in the pack |
2020-11-15 03:26:34 +01:00
| timeout | 120 | How often in seconds the widget refreshes |
2019-12-15 21:38:54 +01:00
2020-07-14 17:01:04 +02:00
### Icons:
2020-11-15 03:26:34 +01:00
The widget comes with two predefined icon packs:
2020-07-14 17:01:04 +02:00
2020-11-15 03:26:34 +01:00
- weather-underground-icons taken from [here](https://github.com/manifestinteractive/weather-underground-icons)
- VitalyGorbachev taken from [here](https://www.flaticon.com/authors/vitaly-gorbachev)
2020-07-14 17:01:04 +02:00
To add your custom icons, create a folder with the pack name under `/icons` and use the folder name in widget's config. There should be 18 icons, preferably 128x128 minimum. Icons should also respect the naming convention, please check widget's source.
### Examples:
#### Custom font, icons
2022-01-24 01:17:02 +01:00
![example1](./example1.png)
2019-12-15 21:38:54 +01:00
```lua
2020-07-14 17:01:04 +02:00
weather_curl_widget({
api_key='<your-key>',
coordinates = {45.5017, -73.5673},
time_format_12h = true,
2019-12-15 21:38:54 +01:00
units = 'imperial',
2020-07-14 17:01:04 +02:00
both_units_widget = true,
font_name = 'Carter One',
icons = 'VitalyGorbachev',
2021-04-13 03:39:49 +02:00
icons_extension = '.svg',
2020-07-14 17:01:04 +02:00
show_hourly_forecast = true,
show_daily_forecast = true,
2019-12-15 21:38:54 +01:00
}),
```
2020-07-14 17:01:04 +02:00
#### Only current weather
2022-01-24 01:17:02 +01:00
![example2](./example2.png)
2020-07-14 17:01:04 +02:00
```lua
weather_curl_widget({
api_key='<your-key>',
coordinates = {45.5017, -73.5673},
}),
```
2018-09-25 01:18:45 +02:00
2020-07-14 17:01:04 +02:00
## Installation
2018-09-25 01:18:45 +02:00
2020-11-15 03:26:34 +01:00
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> ):
2018-09-25 01:18:45 +02:00
```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/
```
2020-11-15 03:26:34 +01:00
1. Get Open Weather Map app id here: [openweathermap.org/appid](https://openweathermap.org/appid).
2019-01-27 04:59:45 +01:00
2018-10-16 18:36:33 +02:00
1. Require weather widget at the beginning of **rc.lua**:
2018-09-25 01:18:45 +02:00
```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-12-15 21:38:54 +01:00
--default
weather_widget({
2020-07-14 17:01:04 +02:00
api_key='<your-key>',
coordinates = {45.5017, -73.5673},
}),
,
--customized
weather_curl_widget({
api_key='<your-key>',
coordinates = {45.5017, -73.5673},
time_format_12h = true,
2019-12-15 21:38:54 +01:00
units = 'imperial',
2020-07-14 17:01:04 +02:00
both_units_widget = true,
font_name = 'Carter One',
icons = 'VitalyGorbachev',
2021-04-13 03:39:49 +02:00
icons_extension = '.svg',
2020-07-14 17:01:04 +02:00
show_hourly_forecast = true,
show_daily_forecast = true,
}),
2018-09-25 01:18:45 +02:00
...
```
2020-11-15 03:26:34 +01:00
## More screenshots
Only negative temperature:
2022-01-24 01:17:02 +01:00
![negative](./negative.png)
2020-11-15 03:26:34 +01:00
Both positive and negative tempertature:
2022-01-24 01:17:02 +01:00
![both](./both.png)
2020-07-14 17:01:04 +02:00
## How it works
TBW