Weather in Screen Statusbar


Caspar Clemens Mierau recently wrote about a nifty Debian package named weather-util and his method for embedding the current temperature into the screen status bar. Quite nifty. I did the same with one small exception, including the predicted probability of precipitation if it exists.

My one liner that runs from cron (split to multiple lines for readability):

 weather -iKACY -f | head -n 9  | \
     awk '/Temperature/ { print $2 "F" }
          /Relative/ { print $3 }
          /precipitation/ { sub (/ chance of.+$/, ""); print "POP " $NF }' | \
     xargs echo > /home/michael/.weather

More details on the full implementation in the original post over at Caspar Clemens Mierau’s blog. And yes, I stole his loadavg stuff too ;)

UPDATE:

Silly me, upon further investigation, two things to note. First, the -i option applies only to current conditions and not to the forecast. In my case I actually want weather -f ACY and /etc/weatherrc takes care of the rest. Secondly, the field number for the precipitation percentage changes, oops. I’ve correctly accounted for this in the updated awk script above.

After making these changes I decided the awk script was getting a bit long for a single line so I went all out creating ~/bin/weather.awk:

#!/usr/bin/awk -f

/Temperature/       { temp = $2 }
/Relative Humidity/ { rh = $3   }
/precipitation/     { sub (/ chance of.+$/, "");
                      precip = $NF;
                      exit
                   }

END{ print temp "F " rh " POP " precip }

My crontab entry now looks like:

*/5 * * * *     weather -f ACY | /home/michael/bin/weather.awk > /home/michael/.weather

Much simpler.

Tags: , ,

One Response to “Weather in Screen Statusbar”

  1. [...] Fri 21-11-2008 Un-quarantine downloaded files on OS X Saved by KillerBen107 on Fri 14-11-2008 Michael Greb: Weather in Screen Statusbar Saved by freefloatinghippy on Wed 12-11-2008 Creating Commands with xargs Saved by Gromoslawski [...]

Leave a Reply