A simple weather module for Waybar based on data from OpenWeatherMap that also comes with a handy CLI.
- Obtain a valid API key from OpenWeatherMap (the free tier is enough)
- Change the
API_KEY
variable in the script to your API key - Get the coordinates of the place you want to receive the data for by running
./weather.py geocoding <city[,state][,country]>
with an appropriate search term, e.g../weather.py geocoding London,CA
for London, Canada. - Change the
LATITUDE
andLONGITUDE
variables in the script to the values received in the previous step
The available subcommands for CLI usage, besides the already discussed
geocoding
are:
current
: information about current weather conditionsforecast[-daily]
: forecast data for the next ~5 days, dailyforecast-detail
: forecast data for the next ~5 days in 3h intervals
Sample usage: ./weather.py current
To integrate the weather widget with Waybar, create a custom module:
"custom/weather": {
"exec": "~/.config/waybar/weather.py waybar",
"restart-interval": 900,
"return-type": "json",
},
Remember to change the path to the weather.py
script specified within the
exec
field.
Then, include the custom/weather
module in your desired module list.
By default, the module will display the current weather category and temperature in the bar. When hovering the mouse over the widget, a tooltip will pop up with detailed information about the current weather and a forecast for the next ~5 days.
The colors used within the widget and tooltip may be changed in the
weather.py
script in order to match your colorscheme.