Weather display script for i3blocks status bar. Fetches weather information from wttr.in and displays it in your status bar with an interactive popup for detailed forecasts.
- Clone this repository:
git clone https://github.com/hastinbe/i3blocks-weather.git
cd i3blocks-weather- Make the script executable:
chmod +x weather-
Configure your
i3blocksconfig file (typically~/.config/i3blocks/config):Add the weather block configuration to your i3blocks config. See
i3blocks.conffor a complete example. The basic configuration:
[weather]
full_text=☂ฺ ☀ฺ Weather ☂ฺ ☀ฺ
command=~/i3blocks-weather/weather
interval=1800
color=#8ec07c
#separator=true
separator_block_width=20Replace ~/i3blocks-weather/weather with the actual path to the weather script.
The script requires the following dependencies:
curl- For fetching weather data from wttr.inrofi- For displaying the interactive weather popupjq- For parsing JSON configuration from i3wm
Install dependencies on:
- Debian/Ubuntu:
sudo apt install curl rofi jq - Arch Linux:
sudo pacman -S curl rofi jq - Fedora:
sudo dnf install curl rofi jq
Add the weather block to your i3blocks configuration as shown in the installation section. The script will:
- Display weather information (temperature, wind, condition icon, humidity) in your status bar
- Update automatically every 30 minutes (1800 seconds) as specified by
interval - Show a detailed ASCII weather report when you click on the block (left-click)
The script displays weather information in the following format:
- Full line:
ICON TEMPERATURE WIND 💧HUMIDITY - Short line:
TEMPERATURE - Color: Dynamically set based on weather conditions (sunny, cloudy, rainy, snowy, foggy)
Click on the weather block in your status bar (left-click) to open an interactive rofi popup showing:
- Full ASCII weather report from wttr.in
- Detailed forecast information
- Current conditions and extended forecast
The popup automatically matches your i3bar colors and font settings.
This script was designed as an enhanced alternative to rofi-wttr from i3blocks-contrib. Below is a feature comparison:
| Feature | i3blocks-weather | rofi-wttr |
|---|---|---|
| Caching | ✅ Yes (15 min default, configurable) | ❌ No |
| Lock file | ✅ Yes (prevents concurrent runs) | ❌ No |
| Color coding | ✅ Yes (automatic based on conditions) | ❌ No |
| Config file | ✅ Yes (~/.config/i3blocks-weather/config) |
❌ No |
| Error handling | ✅ Yes (fallback to cache, dependency checks) | ❌ No |
| Auto-detect i3 colors | ✅ Yes (matches bar colors/font) | ❌ No |
| Customizable format | ✅ Yes (via FORMAT variable) |
|
| Units selection | ✅ Yes (US/metric via UNITS) |
|
| Debug mode | ✅ Yes | ❌ No |
| Structured output | ✅ Yes (full/short/color lines) | |
| Complexity | Higher (~335 lines) | Lower (~70 lines) |
| Dependencies | curl, rofi, jq | curl, rofi |
| Offline support | ✅ Yes (uses cache) | ❌ No |
| Cache control | ✅ Yes (configurable duration, set to 0 to disable) | ❌ No |
i3blocks-weather provides a more robust solution with:
- Performance: Caching reduces API calls and provides instant responses
- Reliability: Lock files prevent race conditions; error handling with fallbacks
- User Experience: Automatic color coding, color/font matching with i3bar
- Flexibility: Extensive configuration options via config file or environment variables
- Offline capability: Works with cached data when network is unavailable
rofi-wttr is better for:
- Simplicity: Easier to understand and modify (~70 lines)
- Minimal dependencies: Doesn't require
jq
i3blocks-weather looks for a configuration file located at either ~/.config/i3blocks-weather/config, or $XDG_CONFIG_HOME/i3blocks-weather/config. You can use this file to set any variables that are not set in the command line or environment.
Create the configuration directory and file:
mkdir -p ~/.config/i3blocks-weatherThen edit ~/.config/i3blocks-weather/config with your settings. By default, the script will auto-detect your location based on your IP address. For example, if you want to always use metric units:
UNITS="m"
CACHE_DURATION=1800Or if you want to set a specific location:
LOCATION="Bismarck,ND"
UNITS="m"
CACHE_DURATION=1800Or if you want to customize the popup appearance and use a custom location:
LOCATION="Paris,France"
UNITS="m"
ROFI_WIDTH="70%"
ROFI_CONFIG_FILE="$HOME/.config/rofi/config.rasi"
DEBUG=0Now every invocation of the script will use these settings, unless overridden by environment variables or command line options.
| Variable | Description | Default |
|---|---|---|
LOCATION |
Weather location (city name, postal code, or coordinates). Leave empty to auto-detect based on IP | "" (auto-detect) |
FORMAT |
wttr.in format string for weather data | %t+%w+%c+%h |
UNITS |
Temperature units: u (US), m (metric), M (metric with wind in m/s) |
u |
CACHE_DURATION |
Cache duration in seconds | 900 (15 minutes) |
CACHE_FILE |
Path to cache file | /tmp/weather-wttr-cache.txt |
POPUP_CACHE_FILE |
Path to popup cache file | /tmp/weather-wttr-popup-cache.txt |
BAR_ID |
i3bar identifier (auto-detected if not set) | Auto-detected |
ROFI_CONFIG_FILE |
Path to rofi config file | /dev/null |
ROFI_WIDTH |
Width of rofi popup window | 65% |
ROFI_LOCATION |
Location of rofi popup window | northwest |
FONT |
Font for rofi popup (auto-detected from i3bar if not set) | Auto-detected |
WEATHER_BG |
Background color for rofi popup (auto-detected from i3bar) | Auto-detected |
WEATHER_FG |
Foreground color for rofi popup (auto-detected from i3bar) | Auto-detected |
DEBUG |
Enable debug output (set to 1 to enable) |
0 |
LABEL |
Optional label prefix for the weather display | Empty |
By default, the script will auto-detect your location based on your IP address. You can set a specific location in several ways:
- Using a configuration file (recommended):
# ~/.config/i3blocks-weather/config
# Leave LOCATION unset or empty to auto-detect, or set a specific location:
LOCATION="Bismarck,ND"
# or
LOCATION="58501" # Postal code
# or
LOCATION="48.8566,2.3522" # Coordinates- Using environment variables:
export LOCATION="Bismarck,ND"- In your i3blocks config:
[weather]
full_text=☂ฺ ☀ฺ Weather ☂ฺ ☀ฺ
command=env LOCATION="Bismarck,ND" /path/to/this/repo/weather
interval=1800u- US units (Fahrenheit, mph)m- Metric units (Celsius, km/h)M- Metric units with wind in m/s
Set in your config file:
# ~/.config/i3blocks-weather/config
UNITS="m"Or using environment variables:
export UNITS="m" # Use metric unitsThe FORMAT variable controls which weather data is fetched. Default format %t+%w+%c+%h includes:
%t- Temperature%w- Wind%c- Condition emoji%h- Humidity
See wttr.in format documentation for all available format options.
The script automatically assigns colors based on weather conditions:
| Condition | Icon | Color |
|---|---|---|
| Sunny | ☀️ | #FFCC66 |
| Partly Cloudy | 🌤️ ⛅ 🌥️ | #ADD8E6 |
| Rainy | 🌦️ 🌧️ ⛈️ | #4169E1 |
| Snowy | ❄️ 🌨️ | #E0FFFF |
| Foggy | 🌫️ | #D3D3D3 |
| Unknown | (none) | #ffffff |
- Check that all dependencies are installed:
which curl rofi jq- Test the script manually:
DEBUG=1 /path/to/weather- Verify your location is valid by testing with curl:
curl "https://wttr.in/YourLocation?format=%t+%w+%c+%h"- Ensure rofi is installed and working:
rofi -version- Check that i3wm is running (required for bar config detection):
i3-msg -t get_version- Enable debug mode to see what's happening:
DEBUG=1 /path/to/weatherIf you're seeing stale weather data, you can:
- Manually delete the cache files:
rm /tmp/weather-wttr-cache.txt /tmp/weather-wttr-popup-cache.txt- Reduce the
CACHE_DURATIONin the script (line 24)
i3blocks-weather is released under GNU General Public License v2
Copyright (C) 2024 Beau Hastings

