How To Customize Your Desktop with GeekTool
Posted 05/05/2011 at 2:00pm
| by Cory Bohon
4. Display iTunes Playing Info
To display the currently playing iTunes song information, we will need to rely on an AppleScript and Geeklet to get the job done. The AppleScript can be downloaded by clicking here, or you can follow along to learn how to compile the AppleScript.

The first thing that we need to do is open the AppleScript Editor found in /Applications/Utilities. Once the application is opened, copy and paste the following script in:
on run
set info to ""
tell application "System Events"
set runCount to count (every process whose name is "iTunes")
end tell
if runCount > 0 then
tell application "iTunes"
if player state is playing then
set _artist to artist of current track
set _title to name of current track
set _album to album of current track
set info to _title & return & _artist & return & _album as string
end if
end tell
end if
return info
end run

Next, click File > Save in the AppleScript Editor. In the save dialog, type in the Save as name of "itunes-playing" and choose your home directory as the save location. Next, ensure that "Script" is selected in the File Format drop-down menu.
If you downloaded our script code, just unzip it and place the itunes-playing.scpt file in your home directory.

Now it's finally time to put all of the pieces together. Open GeekTool and drag a new Shell Geeklet to the desktop. In the Command text box, enter the following command:
osascript ~/itunes-playing.scpt
Next, set the refresh rate to every 10 seconds. You can then tweak the text properties as you see fit. You should now see the song title, artist, and album name whenever that information is available through iTunes.
If you also want to display the album artwork of the song with GeekTool, check out this great post by Mac OS X Hints to see how it's done.
5. Display Current Weather Conditions

The majority of us at Mac|Life are weather geeks (or we at least like to know if it's raining outside), so it only makes sense that we would display the current weather conditions on our desktop with GeekTool. To do this, open GeekTool and drag a new shell Geeklet to your desktop. Click on the ellipses next to the Command window again. In the Command Edit Script box, paste in the following command:
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOURCITYCODE&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///' -e 's/<\/description>//'
Replace the text "YOURCITYCODE" on the first line of the code with your postal code. Close the Edit Script box and click on Yes to save your changes. This will enable Yahoo Weather to deliver the XML containing the weather information for your city. The rest of the code will parse the XML, digging out only the information we want: The weather condition and the temperature.
The above code gives you temperature in degrees Fahrenheit, but if you need it to be in Celsius, you can swap about the above code for this:
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOURCITYCODE&u=c" | grep -E '(Current Conditions:|C<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//'
After entering the code, you can tweak the text properties to your liking.
6. Display System Information
Sometimes you need to have your system information handy for troubleshooting or technical support. Whatever the reason, GeekTool can accommodate. In this section, we'll show you how to display your internal and external IP addresses, display the AirPort transmission rate, and display the up time of your computer.
For each of the following scripts, you will need to drag and drop a new shell Geeklet on your desktop with a refresh rate of 10 seconds and whatever text properties you prefer.

To display your Ethernet, wireless, and external IP address, enter the following code into the Command text box:
myen0=`ifconfig en0 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
if [ "$myen0" != "" ]
then
echo "Ethernet: $myen0"
else
echo "Ethernet: INACTIVE"
fi
myen1=`ifconfig en1 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
if [ "$myen1" != "" ]
then
echo "Wireless: $myen1"
else
echo "Wireless: INACTIVE"
fi
wip=`curl --silent http://checkip.dyndns.org | awk '{print $6}' | cut -f 1 -d "<"`
echo "External: $wip"

To display your AirPort transmission rate, you must first enable the "airport" command by opening Terminal (located in /Applications/Utilities) and typing in the following command:
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
You will be asked to type your administrator password to continue.
After you have done that, you can create a new shell Geeklet with the following command to display the AirPort transmission rate:
mytr=`airport -I | awk '/lastTxRate/ {print $2}'`
if [ "$mytr" != "" ]
then
echo "Airport Transmit Rate: $mytr"
fi

To display the up time of your computer, create a new shell Geeklet and type or paste in the following into the Command text field:
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}'
This command will get the days, hours, and minutes that your computer has been turned on. You may format the text to your liking.
7. Create a Simple Desktop To Do List
Reminders are great, and when you can put them in a conspicuous place they work a lot better. So, why don't we use GeekTool to make a to do list right on our desktop. To do this, we will need to first create a new plain text file to store our to do list in. So, open TextEdit located in /Applications and type in the items you want on your list (or reminders to yourself).

Before saving your to do list, go to Format > Make Plain Text. After you have done that, save the text file in your home folder as "list.txt".

Next, in GeekTool, drag a File Geeklet to your desktop. In the File drop-down menu select "Choose." Use the file browser to find the "list.txt" file that you saved in your home directory. After selecting that file, it will show up on your desktop. As you edit your text file in TextEdit, the desktop version will automatically get updated.
Follow this article's author, Cory Bohon on Twitter.