> _ 

c u t u p @ c u t u p . o r g

 xml 

[geektool weather] last modified: 03/25/2007 02:03 pm

screenshot

My weather desktop using geektool, weather.com, and wunderground.com.

Open geektool preference pane, new entry, set the drop down to picture, paste the url or a picture, and set the refresh rate to something nice that doesnt get us in trouble, like 1800 (seconds). The weather.com photo/maps are nice because the picture name remains the same as it updates. I made four of these and arranged them swankly.

For the center forecast part, I used a shell command (new entry -> shell). I used wunderground cause i can get a fairly uncluttered html page to parse. Weather.com's page is huge and awful, but they do provide an rss feed that might be more polite to gank data out of. But anyhoo, first I grab the data with lynx:

/sw/bin/lynx -dump http://printer.wunderground.com/cgi-bin/findweather/getForecast?query=ZIPCODE

then pipe it into awk:

awk '/Temp/ || /Wind/ || /Cond/ && !/Fore/ {printf $1 ": "; for (i=2; i<=10; i++) printf $i " " }'

This throws away all the lines except Temperature, Wind, and Conditions (and excludes the 'Forecast and Conditions' line), and prints it all on one line. Another site would need a different awk line, but you get the idea.

Join the two lines above with a pipe (|), paste into geektool as one long line and set the color and font and background and everything and, neat desktop. I put a echo; before the first command to generate a newline, so it was more centered on the background.

To use noaa.gov weather is a bit trickier. go to this page http://weather.noaa.gov/weather/PAccus.html, where instead of PA is your two letter state code. Then select a location from the drop-down list "Current Weather Conditions". This will be the url you want to grab with lynx. And the awk will be:

awk '/Sky/ || / Temp/ || /Wind /' | head -n 3 | awk '{printf $0}'



[All Posts] [top]

tags:

geektool
weather