A weather module for Waybar (or any status bar that supports JSON data), using data from the OpenWeatherMap API.
Wayther is written in Haskell*, and uses the Aeson library to parse JSON data from the OpenWeatherMap API.
Build dependencies are managed with Nix. If you're using direnv, just direnv allow the directory. Otherwise, run nix-shell. The pure flag is only necessary if you already have Haskell/Cabal installed, in which case the local packages can end up getting overridden by the global ones.
nix-shell --pureThat should provide the build tools and libraries. Then run hpack to generate the cabal file for building:
hpackThen build:
cabal buildThe executable will be buried somewhere in the dist-newstyle directory tree, as is Cabal's wont. Copy the wayther executable to somewhere sensible, like ~/.local/bin, to install it.
Wayther looks in $HOME/.config/ and ~/.config/ for wayther/config.json.
The config file has the following format:
{
"api":
{
"api_key": "<OpenWeatherMap api key>",
"location": "<{city},{state},{country code}>"
}
}Both api_key and location are necessary. The free tier key at OpenWeatherMap works fine for the API key.
Run as a custom type in Waybar (e.g., custom/weather). Setup in Waybar config is as follows:
"custom/weather": {
"return-type": "json",
"exec": "<PATH/TO/EXECUTABLE>",
"interval": 600
}- Add a Fahrenheit option
- Add more information in the tooltip
- There's a lot more to get out of the API, and making use of that was pretty much the whole point
- Use
geoclue2to get location automatically
Couldn't this have been written much more easily in, say, Python? Uh huh. With the right API, jq would have probably been able to do the job. But everyone ✨deserves✨ a monadic, type-safe weather bar module.