Awesomewm Weather Widget Based on wttr
Inspired by The Streetturtle Weather Widget, wttr-widget use wttr under the hood and does not need any API key.
This widget has three modes :
- Used in the widget-bar :
- Used as a tooltip when mouse enter hover the widget in the widgets-bar :
- Used in a terminal popup to fetch the forecasts clicking on the widgets :
It is possible to customize the widget by providing a table with all or some of the following config parameters :
Name | Default | Description |
---|---|---|
location | "Oymyakon" | See the supported location types |
timeout | 120 | Refresh timeout |
format | "%c%t/%f+%m" | The online output used in the widget-bar. See the One-line output |
format_tooltip | "%c%C+🌡️%t/%f+💦%p/%h+💨%w+〽%P+%m" | The online output used in the tooltip. |
font | beautiful.font:gsub("%s%d+$", "") .. " 9" |
The font to use in the widget bar/tooltip |
units | "m" | See the supported units |
lang | "ru" | See the supported languages |
terminal | "urxvt" | The terminal used to see the forecasts |
local weather_widget = require("wttr-widget.weather")
local wttr = weather_widget({
location = "ccf",
lang = "fr",
}),
-
Clone this repo under ~/.config/awesome/:
git clone git@github.com:pivaldi/wttr-widget.git ~/.config/awesome/wttr-widget
-
Require weather widget at the beginning of rc.lua:
local weather_widget = require("wttr-widget.weather")
-
Add widget to the tasklist:
s.mytasklist, -- Middle widget { -- Right widgets layout = wibox.layout.fixed.horizontal, ... weather_widget({ location = "ccf", lang = "fr", }), ...
In order to place a widget only in one monitor, you can use this snippet :
local my_text_font = beautiful.font:gsub("%s%d+$", "") .. " bold 9"
local weather_widget = require("wttr-widget.weather")
local wttr = weather_widget({
location = "ccf",
lang = "fr",
font = my_text_font,
})
…
awful.screen.connect_for_each_screen(function(s)
…
local weather_wdg = nil
if s == screen.primary then
weather_wdg = {
layout = awful.widget.only_on_screen,
screen = screen.primary, -- Only display on primary screen
wttr,
}
end
-- Create the wibox
s.mywibox = awful.wibar({
position = "top",
screen = s,
bg = beautiful.pi_wibar_bg,
})
-- Add widgets to the wibox
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
…
},
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
…
weather_wdg,
…
},
}
end
)
It is possible to bind key shortcut with toggling tooltip or opening terminal forecast :
awful.key({"Mod4",}, "m", wttr.toggle_tooltip,
{description="show wttr weather tooltip", group="awesome"}),
awful.key({"Mod4", "Shift"}, "m", wttr.show_forecast,
{description="show wttr weather forecast", group="awesome"}),