DailyZen in GeekTool

syldesk-zencropped-smI have been playing with GeekTool the last few days. It’s a small app for Mac OS X (preferences pane, actually) that adds text and images directly to the desktop. It’s highly scriptable and customizable, with people adding anything from the date and time, to log files, to RSS feeds and live satellite photos.

One thing I’ve added to my own desktop, is the Zen poem posted daily on the website DailyZen.com. It took a little work to be able to do it, so I thought I’d post my script. This is based  on the script to fetch a quote from Encarta as posted on Flickr by barm, so credit goes to him for getting me started.

This can all be pasted into GeekTool itself, or you can create a separate shell script (eg. dailyzen.sh), which is what I’ve done, for easy editing. It’s a short one-liner, but there’s a lot going on:

curl -s http://www.dailyzen.com/ | sed -n "/<\!--Add Quote for correct day-->/,/<\/TD>/p"|sed -e "s/<[^>]*>//g" |strings|fold -sw60

curl of course is the Unix utility to fetch an URL, and grabs the contents of the front page of http://www.dailyzen.com/. sed then extracts the portion between the comment and the closing </TD> tag, which contains the poem. The second sed command strips all HTML tags. I used strings to reliably get rid of some stray carriage returns, and finally fold wraps the poem to a nice width without breaking words, as GeekTool would do otherwise.

The script is straightforward to add to GeekTool, it’s simply a Shell command (either pasted in, or calling the dailyzen.sh file). I set the refresh time to 21600; 6 hours is enough to make sure it’s updated in the morning. I used Book Antiqua Italic 20pt for the text, white with 20% opacity.

And here’s the end result:

Sylvan Korvus - GeekTool Desktop

My GeekTool Desktop, with DailyZen quote

3 Responses to “DailyZen in GeekTool”

  1. just found this script, exactly what I was looking for, thanks for posting it

  2. Could you please also post the codes for the time, the day and the weather?
    Thanks,
    Robin

  3. I am so glad that you have this script. Users come to my site looking for GT scripts and my quote of the day script wasn't working. It was using an RSS feed from Encarta and they no longer had an RSS feed for quotes. Anyways, I added your link to my updated list. Awesome script!!!