hmmm....

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):

1
2
3
4
5
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:

1
2
3
4
5
6
7
8
9
10
#!/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.

Comments