waybar-weather

Crates.iowaybar-weather
lib.rswaybar-weather
version0.2.7
created_at2025-06-08 17:54:12.747867+00
updated_at2025-06-14 14:21:27.876925+00
descriptionA waybar module to display the current weather using the OpenWeatherMap API
homepage
repositoryhttps://gitlab.com/baconisaveg/waybar-weather
max_upload_size
id1705113
size186,037
BaconIsAVeg (BaconIsAVeg)

documentation

README

Waybar Weather

Crates.io Version Crates.io Downloads Gitlab Pipeline Status

Simple widget for displaying the current weather information for a given location using the OpenWeatherMap API.

[[TOC]]

Designed for use with Waybar, though it may work with other status bars that support JSON output as well.

You will need to obtain a free API key from OpenWeatherMap using the Current weather and Forecasts API. Once you've created a new API key, it can take up to 30 minutes to become active.

Important: You will also need a nerd patched font to display the weather icons. You can find one at Nerd Fonts. Many distributions already include these fonts, so you may not need to install anything extra.

As a Waybar module

Usage: waybar-weather [OPTIONS]

Options:
  -a, --apikey <APIKEY>        API key for OpenWeatherMap
  -c, --cityid <CITYID>        City ID or Name, ex. London, GB
  -u, --units <UNITS>          Units of measurement [possible values: metric, imperial, standard]
      --high-temp <HIGH_TEMP>  High temperature threshold for 'hot' class
      --low-temp <LOW_TEMP>    Low temperature threshold for 'cold' class
  -h, --help                   Print help
  -V, --version                Print version

The --cityid should be a string with your city and country code, e.g. London, GB or New York, US. You can also use the city ID from OpenWeatherMap, which is a numeric value.

Configuration Options

As an alternative to passing the command line options, the application will look for the following configuration files:

~/.config/waybar-weather/config.yaml
~/.waybar-weather.yaml

An example configuration file is provided in the docs folder.

Installation

From Source

You can install the waybar-weather binary by checking out this repository and then using cargo:

cargo build --release
cargo install --path .

Arch Linux

makepkg -si

From crates.io

You can also install waybar-weather directly from crates.io using cargo:

cargo install waybar-weather

Pre-built Binary

You can download the pre-built binary (amd64) from the Gitlab releases page.

Waybar Configuration

Add the following configuration to your Waybar config file (usually located at ~/.config/waybar/config.jsonc):

"custom/weather": {
  "exec": "~/.cargo/bin/waybar-weather",
  "return-type": "json",
  "interval": 600,
}

And the corresponding CSS to style the widget (usually located at ~/.config/waybar/style.css). Feel free to adjust the CSS to your liking:

#custom-weather {
  padding: 0.3rem 0.6rem;
  margin: 0.4rem 0.25rem;
  border-radius: 6px;
  background-color: #1a1a1f;
  color: #f9e2af;
}

Conditional Styling

You can also add conditional styling based on the weather condition. For example, to change the background color based on the weather condition and have the module blink during adverse conditions, you can use the following CSS:

#custom-weather {
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

@keyframes blink-condition {
  to {
    background-color: #dedede;
  }
}

#custom-weather.hot {
  background-color: #dd5050;
}

#custom-weather.cold {
  background-color: #5050dd;
}

#custom-weather.rain,
#custom-weather.snow,
#custom-weather.smoke {
  color: #dedede;
  animation-name: blink-condition;
  animation-duration: 2s;
}

Credits

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 51

cargo fmt