Mac OS X Only: Geektool

One of my favorite applications for OS X is GeekTool – a simple application that lets you embed files, images, and basic scripts on your desktop. At first I was only using GeekTool to provide me with the date and time, but recently I’ve expanded the number of scripts I have to include some system information and the local weather. While some of you may ask why I don’t just use Snow Leopard’s Dashboard and some of the great widgets available, this approach allows me to see all of this information without ever having to move off of the space I am currently working on; a huge advantage when I’m in the middle of coding something and don’t want to lose focus.

For those of you that may have missed my sneak peak post, here’s my current GeekTool setup:

Click to Enlarge

In the next few sections, I’m going to break my desktop down by the GeekTool groupings (Date & Time, Weather, System Information, and Audio), and provide you with the code that allows you to create each script. I’ve gathered the various scripts used over the past few months, and take no credit for the creation of any of them. Unfortunately, I don’t have the bookmarks for the origins of them, so if there are any issues of legality with this post, please send me an email.

Date & Time

Click to Enlarge

Month: date +%B
Date: date +%d
Day of the Week: date +%A
Time: date +"%l:%M"
AM/PM: date +"%p"

Setting up the Date & Time scripts are among the easiest ones, and add a great deal of additional functionality to your desktop. Simply copy and paste each of the scripts above into their own shell files. You’ll also want to set the refresh to an appropriate amount – I use 60 seconds for all of the above scripts except for Time which is set to 10 seconds. You can then stylize the text to something that suits you and arrange them as you see fit.


Click to Enlarge

Before providing the Weather scripts, I feel like it needs some explanation. All of the information is pulled from Yahoo’s servers, so you will need to find the appropriate string for your city – its usually in the form of XX####, where XX is your state abbreviation and #### is a four digit code generated by Yahoo. The best way to do this is to go onto Yahoo’s RSS feed and search for you city, and copy it out of the URL. The image of the current weather is a combination of two files: first a script pulls the image from Yahoo and saves it locally, and then the image is displayed on your desktop through GeekTool. This is the only script that needs the full url from Yahoo, and not the RSS feed – check the scripts below if this doesn’t make sense, it will after reading them. Both current weather conditions (on top) and the forecast (on bottom) each require their own script.

Current Weather: curl --silent "" | 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///' -e 's/<\/description>//'

Forecast: echo && curl --silent "" | 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\:\ \(.*\)/\?High\: \1\ Low\:\ \2/" | sed "s/\?\(.*\)/\\1/"

Script: curl --silent "" | grep "forecast-icon" | sed "s/.*background\:url(\'\(.*\)\')\;\ _background.*/\1/" | xargs curl --silent -o /tmp/weather.png\
Image: file:///tmp/weather.png

System Information:

Click to Enlarge

The System Information scripts are made up of 8 individual scripts – highest usage processes, CPU usage, memory usage, local and public IP addresses, system uptime, and 3 for battery information. The majority of the battery information is handled via a Perl script, while the other two scripts use indicators to show the charge status (red for charging, green for charged) and the battery status (red for service needed, green for healthy).

Processes: top -orsize -l1 | grep + | grep -v Load | grep -v COMMAND | cut -c 7-19,76-82

CPU Usage: top -l 2 | awk '/CPU usage/ && NR > 5 {print $3, $4, "\n", $5, $6,"\n", $7, $8}'

Memory Usage: top -l 1 | awk '/PhysMem/ {print "Used: " $8 " \n Free: " $10}'

IP Address:
myen0=`ifconfig en0 | grep "inet " | grep -v | awk '{print $2}'`
if [ "$myen0" != "" ]
echo "Ethernet: $myen0"
echo "Ethernet: INACTIVE"
myen1=`ifconfig en1 | grep "inet " | grep -v | awk '{print $2}'`
if [ "$myen1" != "" ]
echo "Airport: $myen1"
echo "Airport: INACTIVE"
wip=`curl --silent | awk '{print $6}' | cut -f 1 -d "<"` echo "External: $wip"

System Uptime: uptime | awk '{sub(/[0-9]|user\,|users\,|load/, "", $6); sub(/mins,|min,/, "min", $6); sub(/user\,|users\,/, "", $5); sub(",", "min", $5); sub(":", "h ", $5); sub(/[0-9]/, "", $4); sub(/day,/, " day ", $4); sub(/days,/, " days ", $4); sub(/mins,|min,/, "min", $4); sub("hrs,", "h", $4); sub(":", "h ", $3); sub(",", "min", $3); print "Uptime: " $3$4$5$6}'

Battery Information:
Perl Script: Download and change the extension to '.pl'
Perl Script Execution: perl ~/path/to/script/
Charging Status: system_profiler SPPowerDataType | grep Charging | grep Yes > /dev/null
Health Status: system_profiler SPPowerDataType | grep Condition | grep Normal > /dev/null
For both Charging and Health Status, make sure that 'Display status feedback image' is checked.


Click to Enlarge

The Audio information embedded on the desktop is not a GeekTool script, but rather a program. The free version of Cover Stream integrates into iTunes and shows the currently playing song. Only one options need to be changed that makes Cover Stream completely embedded, and that it wont be moved by accident. A nice additional piece of functionality is the ability to control playback by hovering over the album art.

Hopefully this post will help you set up a GeekTool desktop of your own. It's an extremely powerful tool, and if used properly can help you add great amounts of functionality to your desktop. If you have any questions, please post them in the comments below and I'll do my best to help you out.

UPDATE: 12/16/2011 Fixed the download link for the '' Script; my hosting apparently blocked .pl downloads on my server, and it was throwing an error message for anyone who tried to access it. Sorry for the inconvenience.

UPDATE: 1/21/2012 GeekTool, v2 has been published with some updated geeklets to help make your desktop more functional.

This entry was written by Marc Budofsky , posted on Wednesday January 26 2011at 11:01 pm , filed under GeekTool, OS X, Software and tagged , , , , . Bookmark the permalink . Post a comment below or leave a trackback: Trackback URL.

38 Responses to “Mac OS X Only: Geektool”

  • Rocco says:

    I was wondering what the setting is to completely embed Cover Stream into the desktop. For some reason I can’t find out how to embed it and it simply disappears after 20 seconds or so. Thanks.

  • @Rocco, it’s been a while since I’ve messed with the Cover Stream settings, but I believe you should go to the Cover Stream icon in the status bar, right click > Preferences > Visuals. On the visuals tab, I have “Show artwork on the desktop” checked, and the two after (Hide & Movable) unchecked. From what I can remember, those two unchecked ones are what allow it to stay embedded on the desktop. Let me know how it works out.

  • Rocco says:

    I guess I had everything correct, for some reason all that was needed was a reboot and it all works as it should now. Either way thank you for your quick response and thank you for putting the code you used up on this page. Very informative.

  • David says:

    Hey man. Awesome guide.

    I have a slight problem. And I’m realy new at this.

    Regarding the image of the weather, how/ where should i run the script?
    Do i need another program for that?



  • Hey David –

    Thanks for checking out my blog – glad you like it.

    For the weather image, you’re going to use 2 geeklets – the first one is going to be a script that queries Yahoo Weather for the image, and saves it in a local file (‘/tmp/weather.png’). The second one is going to be an image, and that will just take the file saved from the first one and display it on the desktop. The first script to query Yahoo will not have any output – it will just be a box once the command is entered, but you still need to leave it on your desktop.

    Let me know if that helped clear it up – any other questions, just leave a comment.


  • Rutger says:

    Hey Marc,

    Nice guide. Too bad your wallpaper isn’t linked, I really like it.

    The only thing I’m not succeeding in is also the weather image. I understand that the first query saves the .png file and the other recalls it but it’s not working for some reason. I need the image for Maastricht in the Netherlands.

    And the Perl script download is no longer available.



  • Hey Rutger,

    I’m glad the guide was helpful. I actually have the wallpaper saved – here’s a mirror to it on my server; I think it was originally off of DeviantArt.

    Hmmmm, thats interesting that the weather image isn’t working – do you mind sending me the script as your currently have it (with the code updated for your location) and I’ll take a look at it?

    And I just fixed the Perl script – apparently my hosting decided allowing .pl downloads isn’t safe. You can download it as a .txt now, and then just change the extension back to .pl for execution; the only thing you may need to change is the maximum capacity of your battery in the script itself to accurately give you the remaining health.

    Any other questions, please don’t hesitate to post.


  • Ebert says:

    I have been trying really hard to get the weather image to work and so far no luck

  • @Ebert –

    I need a little more information to help you figure this out – can you post the URL that your trying to use?


  • I just tried keying that into my browser and got a yahoo error page. I then tried using my own url, and received the same error page. Other than changing the city/state information, you have the rest of the script the way I have it in the post? I recently got a new computer and copied all of the scripts from that page and haven’t had an issue with them, granted I didn’t change any of the location settings.

  • Ebert says:

    I copied your script and tried it out on mine and nothing shows up? do i have to wait a certain amount to time before it starts working?

  • What’s the refresh value set to on both the script and the image? I use 60s for both. I know it’s a little late to be asking, but you do have another geeklet on your desktop to display the image that the script is saving, correct?

  • Ebert says:

    can you give me the full script with my url in it?

  • Ebert says:

    I did not know that there were two refresh values i only fix the one that is in the geeklet, and as for the second part idk

  • You’ll have two geeklets as follows:

    Script: curl –silent “” | grep “forecast-icon” | sed “s/.*background\:url(\’\(.*\)\’)\;\ _background.*/\1/” | xargs curl –silent -o /tmp/weather.png\

    Image: file:///tmp/weather.png

    The first one is a script that pulls the image from yahoo and saves it on your computer as weather.png. The second one is an image that displays weather.png on your desktop. Let me know if this works for you – a last resort might be for me to create the geeklets on my computer and upload them for you to download.

  • Ebert says:

    do i have to create the image file or do i just copy that into the image url ok geek tool?

  • The image file is created automatically from the script – that line of code navigates to the website, finds the forecast icon and outputs (the ‘-o’ near the end) the image into ‘/tmp/weather.png’. By adding the image geeklet, and pointing it to ‘file:///tmp/weather.png’, you’re retrieving the saved image and displaying it. Each of the geeklets has a refresh timeout – set both of these to 60s.

  • Ebert says:

    still not working but with the script that you gave me the geek let says that there is an error

  • Ebert says:

    are both the geeklets supposed to be scripts or one a script window and the other an image window?

  • One should be a script and the other an image. I just tested it out on my computer and got it to work – I had a small error in the script that I posted for you before, so I’m glad I checked it out. Here are the download links: script & image. Hope this fixes it for you!

  • Ebert says:

    OMFG, thank you so much for helping me out on this. sorry i took up a lot of your time. thank you so very much!!!!!!

  • Patricia says:

    i am so glad i stumbled upon your instructions as yours have been the only ones to work for me.
    my only query: refresh rates for weather, not image but forecast and current w. are set to what? i see u set the image refresh and it’s script to 60″.
    i set my weather forecast and current to 600″

    thanks for your patience and help

  • Hey Patricia –

    Thats great to hear – I’m glad you found the tutorial helpful! I use 60 seconds as the refresh for all of my weather related geeklets. Using 600 seconds isn’t going to be a problem; it just means that instead of updating every 1 minute, you’ll update every 10 – in all reality, I highly doubt the weather will change that much/quickly, so a 10 minute refresh probably places less load on the CPU in the long run.

    Any other questions, please let me know!


  • Patricia says:

    Marc, i have another query:

    how do i make this visible? it is not an rss feed, could not find one. was wondering if hence an entirely different script needs to be created? if so, could u walk me thru it?

    thanks so very much

  • Patricia says:

    forgot to add this:

    did find a rss feed link but i cannot make the geeklet work.

  • Hey Patricia –

    Sorry for taking so long to get back to you. The script would need to be modified to accurately pull the necessary information from that RSS feed. If you look at the script, it is using the ‘grep’ command to search for the term ‘Forecast’ [‘grep -e “Forecast:” -A 2’] and then piping it into the next command [tail] to display only the last few lines. The next set of commands [sed] allows the script to parse and format the text for display. Unfortunately, from the RSS feed you posted, you will not be able to have the weather image on the desktop.

    I hope this helped a little!


  • […] just looking through the analytics and stats for my blog, and realized that almost 1 year later, my Geektool post is generating the most traffic to my site. Given that I recently got a new computer and began using […]

  • patricia says:

    thanks Marc. ok, obviously my rss feed will not work as the “forecast” term is none exist. wondering if then “AKZ222” could be used in place of “forecast”? i am not a programmer. took a php class one semester. struggled and flailed my way thru it. i was so terrible at it, and miserable. i do comprehend the concept just not the execution ;-).
    do only rss feeds work with the script? i tried the forecast link above as well. it too yielded no info.
    i don’t need an image on my desktop. as i am continuing to use the yahoo weather for my area

    sorry for daftness.

  • Andrea says:

    Is there a way to get the temperature in Celsius?

  • @Andrea –

    In the URL, change the end from “u=f” to “u=c”. For example, ‘’ would return the temperature in Celsius for my location. Let me know if you have anymore questions!


  • Brent says:

    This info is appreciated and I’ve done wonders with my desktop with Geek tools. Is there a new script link for the weather forecast icon for the next two days? The weather underground or yahoo forecast icon script I was using no longer works. They may have just changed the link but I’m only at the copy and paste stage with the scripts right now so if anyone can give the script for the forecast icon it would be greatly appreciated.

  • @Brent –

    I’m a little confused by your question… I only have an icon for the current weather conditions, and text for the 2 day forecast. What exactly are you trying to do?


  • Brent says:

    @Marc Bodofsky –

    Yeah I noticed you only had the current days icon but I had a script that pulled weather icons for the next two days as well but it is no longer a valid site or string. I was just wondering if anybody knew how to do the icons for the future since it exist or existed I should say and looked really nice with my Desktop setup.

  • Hector says:

    whats the name of that wallpaper?

  • Hector –

    It’s called ‘Silk Air’ – here’s a download link for it in multiple sizes;


  • Edub says:

    very good info here. I have been using Geektool for some time and had the weather image on my desktop for a very long time then one day it disappeared. I have read on other posts that Yahoo changed something on their end which is why the weather image is no longer visible. Is this true and if so is there a fix? I get the weather information, but no image . Any help would be appreciated. Thanks Edub

  • Edub –

    I was in the same position – I’m pretty sure the way the script was pulling the image became broken due to a change in the way Yahoo displays it. That’s the one major problem with using regular expressions to scrape a website; any changes on the site’s part and the script stops working. Fortunately, I was able to come across an alternative that I’ve been using and that works very well. There’s a writeup and installation instructions from the author available here. If there’s anything not clear in the instructions, let me know – I’ve been using this set of scripts for about 3 months now, and it’s definitely a great fix!


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>