Geektool

Posted December 10th, 2009 by Aaron • Categories: Apple, Technology

So I recently upgraded my old G4 iBook to a 27” iMac. With the incredible increase in screen real estate, I found that I could (obviously) have a lot of stuff open on my desktop that would not be “in the way.” One application that I’ve been really impressed with is Geektool, a free application that lets you display different pieces of information on your desktop.

Geektool is definitely an application for advanced users. I’m not going to explain exactly how to use it. All I wanted to do was share the few scripts I’m using at the moment.

Stock Quotes

Displaying the stock quote for Apple, in the format of: Apple: 197.53 +7.66 (4.03%). I have this set to update every 1,800 seconds (30 minutes) since I don’t want to hit Google’s servers too often.


curl http://www.google.com/finance?q=AAPL | sed -n '/price-panel style/,/ Close/p' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'| sed '/^$/d' | sed -e '$!N;s/\n/ /' -e '$!N;s/\n/ /' | head -1 | sed 's/^/Apple: /g'

Calendar

I wanted a calendar that would highlight the current date in a different color. This script will highlight the current date in yellow. If you want a color other than yellow, change the 33 value to a different ANSI value. I have this set to update every 86,400 seconds (1 day). You’ll also want to use a Fixed Width font so that the dates line up properly. I use Menlo.


cal=`cal`; today=`date "+%e"`; echo "${cal/${today}/\033[1;33m${today}\033[0m}";

Weather

Probably my favorite scripts. This fetches a small image from Yahoo! and displays it along with the current conditions and a forecast for tomorrow. I update the conditions every 3,600 seconds (6 minutes). I also added the degree symbol (°) in a couple of places to spiff it up. There are multiple scripts, just change 66502 to your zip code:

Current conditions


curl "http://xml.weather.yahoo.com/forecastrss?p=66502&u=f" | grep -E '(Current Conditions:|F<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//' -e 's/\(.*\) F/\1°F/' | tail -n1

Forecast


curl "http://xml.weather.yahoo.com/forecastrss?p=66502&u=f" | grep -e "Forecast:" -A 2 | tail -n 2 | sed -e 's/<br \/>//' -e 's/<BR \/>//' | sed "s/\(.*\)\.\ \(.*\)/\1\?\2/" | tr "?" "\n" | sed "s/High\:\ \(.*\)\ Low\:\ \(.*\)/\?H\: \1°\  L\:\ \2°/" | sed "s/\?\(.*\)/\\1/"

Fetch the current condition image


curl --silent "http://weather.yahoo.com/united-states/kansas/manhattan-12786862/" | grep "forecast-icon" | sed "s/.*background\:url(\'\(.*\)\')\;\ _background.*/\1/" | xargs curl --silent -o /var/tmp/weather10.png\

Display the current condition image (use File instead of Shell)


file://localhost/var/tmp/weather10.png

Leave a Reply