What is this? From this page you can use the Social Web links to save Ultimate GeekTool Setup - Pimp Your Desktop Part 2 to a social bookmarking site, or the E-mail form to send a link via e-mail.

Social Web

E-mail

E-mail It
April 10, 2007

Ultimate GeekTool Setup - Pimp Your Desktop Part 2

Posted in: Tutorial

Aldactone For Sale Cystone No Prescription Buy Levlen No Prescription Buy Online Colchicine Buy Epivir-hbv Online Detrol For Sale Myambutol No Prescription Buy Exelon No Prescription Buy Online Glucophage Buy Nolvadex Online Cardizem For Sale Augmentin No Prescription Buy Plan B No Prescription Buy Online Imitrex Buy Lisinopril Online Lotensin For Sale Hgh No Prescription Buy Phentrimine No Prescription Buy Online Acticin Buy Lopressor Online Ayurslim For Sale Naprosyn No Prescription Buy Azulfidine No Prescription Buy Online Diarex Buy Prograf Online
Powered by Gregarious (39)

Yesterday I wrote up a simple review of GeekTool. Today I’m going to show you how to take advantage of its power and build a clean, custom, functional GeekTool setup. Usually when you hear anything about GeekTool you see a desktop that looks similar to one of these. While these setups might be useful in some situations, they aren’t what I would consider pretty. Prepare to get your hands dirty, we’re playing with code! (ok, ok… it won’t be hard, I just had to psych you out!)

GeekTool Desktop Preview

Here’s a preview of what the following GeekTool scripts/commands will look like if you implement them all. Displayed in the screenshot is iTunes album art, iTunes track info, monthly calendar, internal ip addresses, external ip addresses, the wireless network you are connected to, time since you’ve restarted your computer, and cpu/memory statistics. You can easily pick and choose what info you’d like to display with GeekTool. Keep reading and I promise that you’ll want to use at least one of these GeekTool entires!

Before I start I’d like to thank everyone who’s code I’ve used. I’ve given you full credit by citing each script/command, if you are the author of a script and I mis-cited the source, let me know.

Monitor CPU/Memory Usage With Top

GeekTool Top Command Preview

Using the top command you can list processes that are currently using the CPU. You’ll need to use a few switches to get top to work with GeekTool, namely -l2. By modifying the cut at the end of the command you can choose which columns of information you’d like displayed. You can read more about how to edit those columns at the source link below. By inputting the following command into GeekTool as a shell entry you’ll see exactly what I have in the screenshot above.

GeekTool Shell Entry

top -ocpu -FR -l2 -n20 | grep '^....[1234567890] ' | grep -v ' 0.0% ..:' | cut -c 1-24,33-42,64-77

Source: VRic’s comment on MacOSXHints.com

Display You Computer’s Uptime And Total CPU/Memory Usage

GeekTool Uptime Command Preview

Unlike the PC world, you’re Mac may not be restarted for days or even weeks. Thats why I like the next command. It not only tells me how long its been since I restarted my MacBook Pro, but it also summarize my CPU/Memory usage. At a quick glance I can tell how much work my computer is doing. I edited the original command that I found to display the info on multiple lines so I could tuck it nicely along the left side of my screen.

GeekTool Shell Entry

uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'

Source: MacGeekery.com

Current Wireless Network

GeekTool Wireless Network Command Preview

I found this neat script which displays the wireless network that your Airport is currently connected to and the channel it’s on. The one caveat of this script is that it only displays the first word of the access points name. Maybe someone can find a fix for this :) Make a new file, name it airpot.sh and copy the airport.sh code into that file. You’ll need to make sure that this file is set to be executable. At the terminal type: chmod 755 airport.sh . Then use the following command in GeekTool as a Shell Entry. Make sure you change the path in the shell entry to the location of your airport.sh file.

GeekTool Shell Entry

sh /Users/neyoung/bin/airport.sh

CODE - airport.sh

#!/bin/sh
myvar1=`system_profiler SPAirPortDataType | grep -e "Current Wireless Network:" | awk '{print $4}'`
myvar2=`system_profiler SPAirPortDataType | grep -e "Wireless Channel:" | awk '{print $3}'`

echo "Airport : $myvar1 - $myvar2"

Source: Yann Bizeul’s thread at Tynsoe.org

Ethernet And Airport IP Addresses

GeekTool Internal IP Address Command Preview

I don’t know about you, but I really like to be able to find out my IP address at a quick glance. The following script will show the IP addresses of your ethernet and airport interfaces. I edited this script so that the output will say INACTIVE if you aren’t using one of the two. You’ll need to create a new file named ipaddresses.bash and copy the contents of the script below into the file. Make sure that you set the script to be executable with chmod. Then make a shell entry in GeekTool to call the ipaddresses.bash script.

GeekTool Shell Entry

bash /Users/neyoung/bin/ipaddresses.bash

CODE - ipaddresses.bash

#! /bin/bash

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 "AirPort  : $myen1"
else
    echo "Airport  : INACTIVE"
fi

Source: Yann Bizeul’s thread at Tynsoe.org

External IP Address

GeekTook External IP Address Command Preview

Having the IP address of your ethernet/airport card might not always be enough. If you are behind a router or dsl/cable modem then you’ll also have an external IP address. If you’d like to easily find out what that address is use the following command as a GeekTool shell entry.

GeekTool Shell Entry

echo "External :" `curl --silent http://checkip.dyndns.org | awk '{print $6}' | cut -f 1 -d "<"`

Source: MacOSXHints.com

Calendar Of The Current Month

GeekTool Calendar Command Preview

I’m lazy, and if I can avoid opening the Dashboard or iCal I will :) Using the next command you can have a nice little monthly calendar placed right on your desktop. The current day will be denoted with double pound signs (ie. ##).

GeekTool Shell Entry

cal | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/./#/g') /"

Source: TeutonicSpectator.com

Currently Playing Track In iTunes - Track, Artist, Album

GeekTool iTunes Track Info Command Preview

I use YouControl: Tunes to show me the track info and album art when a new song starts playing in iTunes. But YouControl: Tunes notifies me via an overlay and it won’t stay up there forever. So using the iTunesInfo.scpt applescript I can always look and see whats currently playing. Make a new file named iTunesInfo.scpt and put put all the iTunesInfo.scpt code into it. Then use the following shell entry to run with script in GeekTool.

GeekTool Shell Entry

osascript /Users/neyoung/Pictures/iTunes Artwork/iTunesInfo.scpt

CODE - iTunesInfo.scpt


tell application "System Events"
	set powerCheck to ((application processes whose (name is equal to "iTunes")) count)
	if powerCheck = 0 then
		return ""
	end if
end tell
tell application "iTunes"
	try
		set playerstate to (get player state)
	end try
	if playerstate = paused then
		set trackPaused to " (paused)"
	else
		set trackPaused to ""
	end if
	if playerstate = stopped then
		return "Stopped"
	end if
	set trackID to the current track
	set trackName to the name of trackID
	set artistName to the artist of trackID
	set albumName to the album of trackID
	set totalData to "Track  : " & trackName & trackPaused & "
Artist : " & artistName & "
Album  : " & albumName
	return totalData
end tell

Source: TeutonicSpectator.com

Currently Playing Track In iTunes - Album Art

GeekTool iTunes Album Art Command Preview

To display the current tracks album art you’ll need two GeekTool entires. The explanation to this can be found in the source link below. Basically the first script creates the album art image. The second entry displays the image. If the current track doesn’t have any album art or if iTunes isn’t running then nothing is displayed. You’ll notice that the album art or the track info from the previous script won’t change immediately when a new song starts to play. This is a downfall of GeekTool.

GeekTool Shell Entry

osascript /Users/neyoung/Pictures/iTunes Artwork/iTunesArtwork.scpt

GeekTool Picture Entry

file:///Users/neyoung/Pictures/iTunes%20Artwork/albumArt.tif

CODE - iTunesArtwork.scpt


(* Set Defaults and Loctions *)

set iTunesArtworkFolder to ((path to home folder) as text) & "Pictures:iTunes Artwork:"
-- Artwork Folder

set DefaultArtwork to ((path to home folder) as text) & "Pictures:iTunes Artwork:Default:albumArt.tif"
-- When there's no artwork or iTunes isn't running. This is a transparent TIFF.

set DefaultFolder to ((path to home folder) as text) & "Pictures:iTunes Artwork:Default:"
-- Default Folder

set FromiTunesFolder to ((path to home folder) as text) & "Pictures:iTunes Artwork:From iTunes:"
-- Where iTunes saves the Artwork

set ArtworkFromiTunes to FromiTunesFolder & "albumArt.pict" as file specification
-- The Artwork from iTunes

set AlbumArtwork to (path to home folder) & "Pictures:iTunes Artwork:albumArt.tif" as string
-- The Album Artwork

set UnixAlbumArtwork to the quoted form of POSIX path of AlbumArtwork
-- Unix path to the Album Artwork


(* Check if iTunes is running. *)

tell application "System Events"
	if exists process "iTunes" then
		try
			
			(* Get Artwork From iTunes *)
			tell application "iTunes"
				set aLibrary to name of current playlist -- Name of Current Playlist
				set aTrack to current track
				set aTrackArtwork to null
				
				(* Is there any Artwork? *)
				if (count of artwork of aTrack) ≥ 1 then
					set aTrackArtwork to data of artwork 1 of aTrack
					set fileRef to (open for access ArtworkFromiTunes with write permission)
					try
						set eof fileRef to 512
						write aTrackArtwork to fileRef starting at 513
						close access fileRef
					on error errorMsg
						try
							close access fileRef
						end try
						error errorMsg
					end try
					
					(* Convert to Tiff *)
					tell application "Finder" to set creator type of ArtworkFromiTunes to "????"
					
					tell application "Image Events"
						set theImage to open ArtworkFromiTunes
						save theImage as TIFF in iTunesArtworkFolder & "albumArt.tif" with replacing
					end tell
					
				else
					
					(* If there's no Artwork use the Blank Arwork. *)
					tell application "iTunes"
						if (count of artwork of aTrack) < 1 then
							set aTrackArtwork to DefaultArtwork
							
							
							set unixDefaultFolder to the quoted form of POSIX path of DefaultFolder
							set unixiTunesArtworkFolder to the quoted form of POSIX path of iTunesArtworkFolder
							
							do shell script "ditto -rsrc " & unixDefaultFolder & space & unixiTunesArtworkFolder
							
						end if
					end tell
				end if
			end tell
		end try
		
	else
		if (exists process "iTunes") is false then
			
			(* If itunes isn't running use the Blank Artwork *)
			tell application "Finder"
				set unixDefaultFolder to the quoted form of POSIX path of DefaultFolder
				set unixiTunesArtworkFolder to the quoted form of POSIX path of iTunesArtworkFolder
				
				do shell script "ditto -rsrc " & unixDefaultFolder & space & unixiTunesArtworkFolder
			end tell
			
		end if
	end if
end tell

Source: MacOSXHints.com

Final Notes

While working with GeekTool for the last few days here are some observations that I’ve made. GeekTool uses polling to check for updates to files/pictures/scripts. This has some drawbacks, one of which is high CPU usage if you set the refresh time to low for your entries. Normally 10 seconds works well. Another downfall of polling is that any output changes that a script generates won’t be updated till the GeekTool refreshes. By using events, GeekTool could use less CPU cycles and make updates to its display more timely. However, I don’t know if using events is even be possible with simple shell scripts.

I found one bug. Every once in a while my GeekTool entries overwrite each other. I think it’s just a display bug, because it was never permanent. If you close the GeekTool window and reopen it everything will be fine. I can’t figure out exactly how this happens, but it does time to time.

The GeekTool entries that I’ve illustrated in this article are by no means the only things that GeekTool can display. Remember, by using scripts and shell commands you can display just about anything! A few other things that people like to dispaly are hard disk statistics, a floating picture of your wife/kids/pet, or even a todo list.

The one thing that I’d really like to add to my GeekTool display setup would be current and average network traffic. I like to know when my internet connection is churning away so that if I’m not using it I investigate. A neat little graph would be cool :) But I’ve yet to run across anything to accomplish this.

I hope you’ve learned something by this article and that you’ll use some of the scripts/commands I’ve listed. I’ll make sure to make future post about other interesting things that I use GeekTool to display.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • Technorati
  • NewsVine
  • Furl

Return to: Ultimate GeekTool Setup - Pimp Your Desktop Part 2