Weather info in i3status

I recently started using i3wm because it is light-weight, keyboard-friendly and uses the screen real-estate efficiently.  I customized i3bar and i3status (which came installed with i3) to show system information and date/time. But there was no out-of-the-box feature to get weather information from i3 status.

I wanted a simple solution that does not require installing an external program like i3blocksconky, dzen2, xmobar or lemonbar. It had to also preserve colors I had configured for the i3bar output. So I came up with this simple solution.

Step 1: Setup a cron job to retrieve weather information every half hour and store it in a temporary file.

*/5 * * * * curl -s | head -n 7 > ~/.weather.cache

Step 2: Write a shell script to add this information to i3status data.

# shell script to prepend i3status with weather

i3status | (read line && echo "$line" && read line && echo "$line" && read line && echo "$line" && while :
  read line
  temp=$(cat ~/.weather.cache | grep -m 1 -Eo -e '-?[[:digit:]].*°C')
  status=$(cat ~/.weather.cache | head -n 3 | tail -n 1 | cut -c 16-)
  echo ",[{\"full_text\":\"${temp} ? ${status}\",\"color\":\"#00FF00\" },${line#,\[}" || exit 1

Step 3: The~/.config/i3/config file needs to be updated for thestatus_command to pipe through this script, as follows.

bar {
status_command .config/i3/
tray_output primary

Step 4: The~/.i3status.conf file should also be updated to change the output to the JSON format.

general {
output_format = "i3bar"
colors = true
interval = 5

You can find more information from the following links.

Published on System Code Geeks with permission by Keheliya Gallaba, partner at our SCG program. See the original article here: Weather info in i3status

Opinions expressed by System Code Geeks contributors are their own.

Do you want to know how to develop your skillset to become a sysadmin Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. Introduction to NGINX

2. Apache HTTP Server Cookbook

3. VirtualBox Essentials

4. Nagios Monitoring Cookbook

5. Linux BASH Programming Cookbook

6. Postgresql Database Tutorial


and many more ....


I have read and agree to the terms & conditions


Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
1 year ago

Thank you for this, works smoothly!
However, there is an unnecessary “?” at the 9th line of before “${status}”

Last edited 1 year ago by bilibraker
Back to top button