Polybar Modules weather - ulises-jeremias/dotfiles GitHub Wiki
Display current weather conditions with temperature and weather icons in your polybar.
Tip
The weather module fetches data from OpenWeatherMap and displays it with beautiful weather icons and current temperature.
The weather module provides real-time weather information including:
- Current temperature in your preferred unit
- Weather condition icons (sunny, cloudy, rainy, etc.)
- Automatic updates every 10 minutes
- Network connectivity check before fetching data
[module/weather]
type = custom/script
exec = ~/.config/polybar/configs/default/scripts/weather-info
exec-if = ping openweathermap.org -c 1
interval = 600
Property | Value | Description |
---|---|---|
type |
custom/script |
Uses external script for data |
exec |
~/.config/polybar/configs/default/scripts/weather-info |
Script path |
exec-if |
ping openweathermap.org -c 1 |
Check connectivity first |
interval |
600 |
Update every 10 minutes |
🌤️ 22°C
The module shows:
- Weather icon using Nerd Font weather symbols
- Temperature in Celsius or Fahrenheit
- Colored output using system color scheme
You can customize the appearance by modifying the script or adding format options:
[module/weather-custom]
type = custom/script
exec = ~/.config/polybar/configs/default/scripts/weather-info
interval = 600
format = <label>
format-prefix = "Weather: "
format-prefix-foreground = ${colors.primary}
#!/usr/bin/env bash
weather_temp=$(dots-weather-info --temp)
weather_icon=$(dots-weather-info --icon)
foreground="$(xrdb -get "color7")"
echo " %{F${foreground}}%{T5}$weather_icon%{T-}%{F} $weather_temp"
- dots-weather-info: Core weather data fetching utility
- OpenWeatherMap API: External weather service
- Internet connection: Required for data updates
The module displays appropriate icons based on weather conditions:
Condition | Icon | Description |
---|---|---|
Clear | ☀️ | Sunny skies |
Partly Cloudy | ⛅ | Some clouds |
Cloudy | ☁️ | Overcast |
Rain | 🌧️ | Precipitation |
Snow | ❄️ | Snow conditions |
Thunderstorm | ⛈️ | Storms |
-
Get OpenWeatherMap API key:
- Register at openweathermap.org
- Generate a free API key
-
Configure dots-weather-info:
# Set up your API key and location dots-weather-info --setup
- Internet connection for weather data
- OpenWeatherMap access (port 80/443)
- DNS resolution for openweathermap.org
modules-right = weather date
[module/weather-styled]
type = custom/script
exec = ~/.config/polybar/configs/default/scripts/weather-info
interval = 600
format = %{T6}🌤️%{T-} <label>
format-background = ${colors.background-alt}
format-padding = 2
# In bottom bar configuration
modules-center = weather
No weather data displayed:
- Check internet connection:
ping openweathermap.org
- Verify API key configuration
- Check script permissions:
chmod +x ~/.config/polybar/configs/default/scripts/weather-info
Weather data is outdated:
- Check the update interval (default: 10 minutes)
- Manually test the script:
~/.config/polybar/configs/default/scripts/weather-info
- Verify network connectivity
Script errors:
# Test the underlying command
dots-weather-info --temp
dots-weather-info --icon
# Check script output
bash -x ~/.config/polybar/configs/default/scripts/weather-info
Reduce network requests:
# Increase interval to 30 minutes
interval = 1800
Add failure handling:
# Only update if network is available
exec-if = ping -c 1 openweathermap.org && command -v dots-weather-info
Create a custom weather display script:
#!/usr/bin/env bash
# ~/.config/polybar/configs/default/scripts/weather-custom
temp=$(dots-weather-info --temp)
condition=$(dots-weather-info --condition)
icon=$(dots-weather-info --icon)
case "$condition" in
"clear") color="#ffcc02" ;;
"rain") color="#4fc3f7" ;;
"snow") color="#e3f2fd" ;;
*) color="#ffffff" ;;
esac
echo "%{F$color}%{T5}$icon%{T-}%{F-} $temp"
Show weather only during specific hours:
#!/usr/bin/env bash
hour=$(date +%H)
# Only show weather between 6 AM and 10 PM
if [ "$hour" -ge 6 ] && [ "$hour" -le 22 ]; then
~/.config/polybar/configs/default/scripts/weather-info
fi
- ✅ All bar configurations (top, bottom, i3)
- ✅ Any window manager (i3, Openbox, etc.)
- ✅ Multi-monitor setups
- ✅ Rice switching (adapts to color schemes)
- Date/time modules for complete status info
- Network modules for connectivity awareness
- System tray for weather app integration
Stay informed about the weather without leaving your desktop! 🌦️
Tip
Position the weather module in your bottom bar or next to the date for quick reference throughout the day.