-->



Ultimate GeekTool Setup - Pimp Your Desktop Part 2

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

114 Responses to “Ultimate GeekTool Setup - Pimp Your Desktop Part 2”


  1. Gravatar Icon 1 CabbageHunter Apr 11th, 2007 at 2:57 am

    Where did you get your desktop background from?

  2. Gravatar Icon 2 Nick Young Apr 11th, 2007 at 3:23 am

    An artist named el1as had it posted in his DeviantArt Gallery.

    Here’s a link to the image, it’s called In the Dark

  3. Gravatar Icon 3 Vidal van Bergen Apr 11th, 2007 at 5:28 am

    You can use “MenuMeters” to display, amongst others, your network activity.

  4. Gravatar Icon 4 Paul Zovighian Apr 11th, 2007 at 7:22 am

    Wow! Great review, I’m downloading it now :D

  5. Gravatar Icon 5 Mitch Martin Apr 11th, 2007 at 9:42 am

    Thanks for the great review. I am going to download GeekTool and follow your guide as soon as I get home.

    www.tastybooze.com

  6. Gravatar Icon 6 Nick Young Apr 11th, 2007 at 10:57 am

    I actually ran into MenuMeters last night Vidal. I was reading an article at TUAW and they author was talking about all the icons in his menu bar. One of which was MenuMeters. One thing lead to another and I ended up at this site, which lists a bunch of menu bar applications :) Thanks for the suggestion!

    If anyone needs any help setting up GeekTool feel free to ask and I’ll provide any insight that I can.

  7. Gravatar Icon 7 Paul Zovighian Apr 12th, 2007 at 5:14 am

    I personally didn’t like MenuMeters, I had it a whlie back, and I ditched it after two days. I’d rather have that info displayed with GeekTool.

  8. Gravatar Icon 8 Nick Young Apr 12th, 2007 at 6:39 am

    I looked around for a bit and couldn’t find an easy fix to make MenuMeters background transparent. But I did find this neat trick to make the CPU load graph look like fire :)

  9. Gravatar Icon 9 Paul Zovighian Apr 12th, 2007 at 6:51 am

    Wow that’s wicked!

    One stupid question, when you say make a file on your posts, such as “create a new file named ipaddresses.bash” or “Make a new file, name it airpot.sh and copy the airport.sh” are these files made on the Script Editor? Or is it on some other application?

    Thanks

  10. Gravatar Icon 10 Dave Bullock Apr 12th, 2007 at 7:25 am

    Paul - if you’re doing this in terminal type ‘touch ipaddress.bash’ - that will create an empty file with the appropriate filename that you can then insert the text as advised and change permissions if necessary.

  11. Gravatar Icon 11 Paul Zovighian Apr 12th, 2007 at 7:43 am

    Ohhh ok thanks Dave. Never was good with Terminal, didn’t understand it’s purpose, but hey, that’s a use for it! thanks.

  12. Gravatar Icon 12 Dave Bullock Apr 12th, 2007 at 7:48 am

    Personally I find terminal quite comforting - theres a lot of things I can accomplish faster there than pointing and clicking :)

  13. Gravatar Icon 13 Paul Zovighian Apr 12th, 2007 at 8:50 am

    You know what? You’re probably right, I probably just feel the way I do cause I’m really ignorant when it comes to using terminal. Need to start learning how to use it…

  14. Gravatar Icon 14 Nick Young Apr 12th, 2007 at 12:12 pm

    If you have any experience with Linux you’ll find yourself really comfortable with the terminal. You can accomplish a lot of things with it very quickly if you know the right commands and the proper switches.

    For example, when I copied a bunch of pictures onto my MacBook Pro all the permissions were messed up. With a short shell command I was able fix all permissions on 10gb worth of pictures in the matter of a few seconds. Thats just one example, the terminal is VERY powerful.

  15. Gravatar Icon 15 Neil Apr 12th, 2007 at 5:50 pm

    Very cool. I was inspired to do the same, but changed the iTunes script to also work with streaming radio:

    set trackID to the current track
    set trackName to the name of trackID
    set theStream to the current stream title as text
    if theStream is not “missing value” then
    set totalData to “Stream : ” & trackName & trackPaused & ”
    Title : ” & theStream
    else
    set artistName to the artist of trackID
    set albumName to the album of trackID
    set totalData to “Track : ” & trackName & trackPaused & ”
    Artist : ” & artistName & ”
    Album : ” & albumName
    end if
    return totalData

  16. Gravatar Icon 16 Dave Bullock Apr 13th, 2007 at 1:50 am

    If you want to display drive info (mount points, space and so on) use

    df -H -l

    (not mine, found on one of the coutless Geektool hint pages out there :) )

  17. Gravatar Icon 17 Nick Young Apr 13th, 2007 at 2:02 am

    I like that Dave, I’m going to add that to my display :)

  18. Gravatar Icon 18 Dave Bullock Apr 13th, 2007 at 2:33 am

    Yeah, that one’s a permanent fixture on mine too - I particularly like how it includes mouted CDs and DMGs and stuff

  19. Gravatar Icon 19 BobbyW Apr 25th, 2007 at 10:30 am

    On the iTunes Artwork you mention two entries. Is there any need for the first entry to be in GeekTool? I didn’t read the entire script but I assume it copies the artwork image to a place the second GeekTool entry can find it - right?

    So - could a cron job take care of the first part and then you’d just add the second entry to GeekTool? I don’t know if that would save any processing power - probably not - but I was just curious about it.

  20. Gravatar Icon 20 Nick Young Apr 25th, 2007 at 8:23 pm

    Yes, the first script is only needed to create the album art image file. You could theoretically set it up as a chron job. The original author probably just used GeekTool instead of a chron job since he was already using GeekTool to display the iTunes artwork. You should try it both ways and see if using a chron job is better :)

  21. Gravatar Icon 21 Ford Apr 25th, 2007 at 10:21 pm

    Anyone have an idea of how to get rid of that last comma when using the uptime command?

  22. Gravatar Icon 22 Nick Young Apr 25th, 2007 at 11:39 pm

    Ford, here’s what you are looking for. If we pipe the uptime command into sed we can remove the last character of a line with some trickery… sed -e ’s/.$//g’ Here’s the full command to use :)

    uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 }' | sed -e 's/.$//g'; 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}'

  23. Gravatar Icon 23 Ford Apr 26th, 2007 at 7:47 am

    Wow, I have no idea how that sed command works, but it works like a charm…
    I changed my uptime command to be a bit different, here’s what I’m using now:
    echo UPTIME: `uptime | cut -c 11-24` | sed -e 's/.$//g'
    When you use awk, the output sometimes looks like:
    UPTIME: 2 days, 3
    when it should have said:
    UPTIME 2 days, 3 mins
    Using the cut command seems to accomodate for that but I still need to watch it to see how it looks when the time is way different.

    Also, for the top command, wouldn’t it be easier to use tail instead of grep to find the last 20 lines?

    Here’s what I use:
    top -ocpu -FR -l2 -n20 |tail -n21 | grep -v ' 0.0% ..:' | cut -c 1-24,33-42,64-77

    Thanks for the help!

  24. Gravatar Icon 24 Nick Young Apr 26th, 2007 at 11:18 am

    Ford, I tried your uptime change and I think that like the awk solution it works in certain situations. Here’s my output

    UPTIME : 4 days, 15:46

    Notice that min isn’t appended to the line. I’ll take a look at it a bit later and see if I can come up with a fix.

    I think that your use of tail with the top script is optimal. I don’t think that tail does any heavy parsing like grep, which your cpu will appreciate :) Thanks for the heads up!

  25. Gravatar Icon 25 Ford Apr 26th, 2007 at 1:18 pm

    That’s actually how I wanted the output to look. Notice that when you have a time like 15:46, the full output of uptime won’t say mins or hrs, those only show up when it’s been less than 1 hour that day or the minutes are at zero.
    The only thing I have yet to find out about is how it ends up looking when I get into double digits with the days, etc.
    Thanks for your help!

  26. Gravatar Icon 26 Adam Apr 26th, 2007 at 5:22 pm

    Hey Nick,

    Thanks for taking the time to post. I’m a bit of a beginner, and just downloaded Geek Tool today. I had no problem setting up the date, calendar, and Hardrive tracker, but I’m a bit confused how to set up the iTunes tracker. Obviously the shell command shouldn’t be an issue, but I can’t figure out how to make the iTunesInfo.scpt file and insert the command info. Can you help me out?

  27. Gravatar Icon 27 Adrixan Apr 27th, 2007 at 2:38 am

    Hi,

    very nice tips you’ve given on how to use GeekTool!

    Here’s a way I’ve found to display Battery stats:
    /usr/sbin/ioreg -p IODeviceTree -n battery -w 0 | grep IOBatteryInfo

    does anyone of you know a way to display temperature and fan stats, these would be the last missing commands to make this Geektool a full replacement of istat to me!

  28. Gravatar Icon 28 Ford Apr 27th, 2007 at 8:14 am

    Adrixan,
    That’s an awesome way to show the battery info, much better than the way I just discovered:
    system_profiler SPPowerDataType | grep mAh
    I’m still searching for a way to show cpu temperature… it’s gotta be in there somewhere!

  29. Gravatar Icon 29 Adrixan Apr 27th, 2007 at 10:37 am

    Hi,

    I’ve been doing some research on that today, but it doesn’t seem to be very easy to extract these infos, I’ve taken a look into the iStat Pro package, but it doesn’t just use a simple command to get the informations, it seems. Maybe someone else might find a way!

  30. Gravatar Icon 30 Nick Young Apr 28th, 2007 at 3:21 am

    Adam,
    Here’s how you setup the iTunesInfo.scpt file. Open

    /Applications/AppleScript/Script Editor.app

    Now copy and paste the following code into the Script Editor

    
    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  : " &amp; trackName &amp; trackPaused &amp; "
    Artist : " &amp; artistName &amp; "
    Album  : " &amp; albumName
    	return totalData
    end tell

    Now click File > Save As…, put iTunesInfo.scpt as the name and change the file format to Application. Now click Save.

    Now that iTunesInfo.scpt is created open up GeekTool and make a new shell entry. Type the following into the shell entry field.

    osascript /Users/neyoung/code/iTunesInfo.scpt

    Make sure you change /Users/neyoung/code/ to the directory that you saved the iTunesInfo.scpt application to.

    Hope that helped :)

  31. Gravatar Icon 31 Nick Young Apr 28th, 2007 at 3:22 am

    Ford & Adrixan,
    Wow I never thought to try to put the battery info of my MBP in my GeekTool setup. I could get the command that Ford posted to work, but not the one that Adrixan posted. Are you using an Intel Mac Adrixan?

  32. Gravatar Icon 32 Adrixan Apr 28th, 2007 at 3:36 am

    Nick Young,

    no, sorry, I’m stil lusing a 12″ Powerbook, so it might be different for MBP’s maybe there is a similar way to make it give the same output as well. The one I was using was just a snipplet I found while searching for a way to display the information.

  33. Gravatar Icon 33 Nick Young Apr 28th, 2007 at 4:00 am

    Thats probably why I can’t get the info to display :(

    There must be an Intel Mac equivalent to the command that you found. I’ll have a look around and see if I can come up with anything.

  34. Gravatar Icon 34 Adrixan Apr 28th, 2007 at 4:18 am

    Nick,

    I guess that is the problem, I’ve also not been able to find a way to monitor the temperature except for downloading another tool that just does this job and allows you to run it via command line. But for me that’s uninteresting, as I want to use OS X’s built in features only, or maybe a little script.

  35. Gravatar Icon 35 Nick Young Apr 28th, 2007 at 12:42 pm

    Adrixan,

    I ran across a script on MacGeekery that says that allows you to output sensor data to the command line. But, it uses ioreg, just like your battery script so it doesn’t work that well on my Intel Mac. You might have some success with it. I found some apps (Temperature Monitor and another one also named Temperature Monitor)that let you output the temps to the command line as well, but I’d like a pure OS X solution :)

  36. Gravatar Icon 36 Adam Apr 28th, 2007 at 8:17 pm

    Nick,

    Thanks for getting back to me regarding my post about getting the iTunes script running. I just tried to enter the command into Script Editor, and when I try to save I receive a Syntax Error that says: Expected end of line, etc. but found unknown token. I’m not sure what I did wrong. Any ideas?

  37. Gravatar Icon 37 Nick Young Apr 29th, 2007 at 12:01 am

    Adam, I forgot to escape the &’s, my bad :(

    Use the find feature of Script Editor.app (ie Apple F). Then search for & and replace it with &. That should fix your Syntax Error. Good Luck!

  38. Gravatar Icon 38 Adam Apr 29th, 2007 at 12:40 am

    Nick,

    I think I made the changes correctly in Script Editor using the find feature. Remember, I’ve never used this application before. In the find menu, I REPLACED ALL the &’s with &.’s. After, I tried to save it again, and I got a different Syntax Error. This one said the following: “Syntax Error…Expected expression but found unknown token.” Again, I think I performed the task correctly, but I’m not sure. When you get a chance, let me know your thoughts. I really appreciate it.

    Adam

  39. Gravatar Icon 39 Adam Apr 29th, 2007 at 1:17 am

    Nick,

    Just figured it out. Was able to save the script, but its still not working. I think it has to do with the way I’m typing in the Shell command in geektool. How do I find out the directory that I saved the iTunesInfo.scpt application to?

  40. Gravatar Icon 40 Adrixan Apr 29th, 2007 at 3:55 am

    Nick,

    thank you very much for the script, it works great on my Powerbook, now I’ve got all the information I’ve missed after uninstalling iStatPro right on my Desktop!

  41. Gravatar Icon 41 Nick Young Apr 29th, 2007 at 1:03 pm

    Adam,
    Sorry, my fault again. I didn’t review my comment after I posted it. You want to search for amp and replace it with &. that should do the trick. If you want I can just email the script to you and it should avoid all this headache.

    Adrixan,
    Congrats on the GeekTool nirvana!

  42. Gravatar Icon 42 wreck May 11th, 2007 at 4:11 pm

    I cleaned up the IP Address script a bit, addeded the external address as well.

    #! /bin/bash
    echo “External :” `curl –silent http://checkip.dyndns.org/ | awk ‘{print $6}’ | cut -f 1 -d “

  43. Gravatar Icon 43 wreck May 11th, 2007 at 4:14 pm

    Looks like it got cut off at the bracket

    "<"
    #! /bin/bash
    echo “External :” `curl –silent http://checkip.dyndns.org/ | awk ‘{print $6}’ | cut -f 1 -d "<"`
    myen0=`ifconfig en0 | grep “inet ” | grep -v 127.0.0.1 | awk ‘{print $2}’| grep -v inet`

    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}’| grep -v inet`

    if [ “myen1″ != “” ]
    then
    echo “AirPort : $myen1″
    else
    echo “Airport : INACTIVE”
    fi

  44. Gravatar Icon 44 Greg Donald May 11th, 2007 at 8:31 pm

    Nice app. Too bad it can’t handle shell colors:

    Black=”\[33[0;30m\]”
    DarkGray=”\[33[1;30m\]”
    LightGray=”\[33[0;37m\]”
    White=”\[33[1;37m\]”
    Blue=”\[33[0;34m\]”
    LightBlue=”\[33[1;34m\]”
    Green=”\[33[0;32m\]”
    LightGreen=”\[33[1;32m\]”
    Cyan=”\[33[0;36m\]”
    LightCyan=”\[33[1;36m\]”
    Red=”\[33[0;31m\]”
    LightRed=”\[33[1;31m\]”
    Purple=”\[33[0;35m\]”
    LightPurple=”\[33[1;35m\]”
    Brown=”\[33[0;33m\]”
    Yellow=”\[33[1;33m\]”

    `tail -f /var/log/secure.log|colorize` doesn’t work :(

  45. Gravatar Icon 45 Francois May 13th, 2007 at 3:19 pm

    Hello and thanks for this tutorial. I tried the iTunes Twicks.

    The one that dispalys current track info worls fine, but I have a problem with the one that displays Artwork.

    I created ~/Pictures/iTunes Artwork folder and all needed stuff, including the script.

    The problem is that I have to run the script manually in order for the right ArtWork to display… di I miss something ?

    Francois

  46. Gravatar Icon 46 Steven May 13th, 2007 at 9:20 pm

    I found this program called CoconutBattery that displays the batteries “Design Capacity”, “Max Capacity”, and “Current Capacity”

    ioreg -w0 -l | grep DesignCapacity
    ioreg -w0 -l | grep MaxCapacity
    ioreg -w0 -l | grep CurrentCapacity

    The output line isn’t pretty so I hide a portion of it off the screen. If anyone knows the terminal, what would someone add to change how the output wold look like.

  47. Gravatar Icon 47 Nick Young May 13th, 2007 at 11:53 pm

    Francois,

    You need to make TWO GeekTool entries. The first is a picture entry and the second is a shell entry. It sounds like you have the picture entry working. Now you just need to make a shell entry to create the album art image so that you don’t have to do it manually. Here is the code that you need to enter as a new shell entry

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

    I hope that this works for you :)

    Steven,

    Ask and you shall receive!

    ioreg -w0 -l | grep DesignCapacity | awk '{ print substr($0,19,50) }' | sed 's/"//g'
    ioreg -w0 -l | grep MaxCapacity | awk '{ print substr($0,19,50) }' | sed 's/"//g'
    ioreg -w0 -l | grep CurrentCapacity | awk '{ print substr($0,19,50) }' | sed 's/"//g'
    

  48. Gravatar Icon 48 Francois May 14th, 2007 at 12:37 am

    Nick,

    Thanks for your help. Let me give you details about what I did…

    I did 3 things :
    1)Create the script (by copying the source you give) and save it in ~/Pictures/iTunes Artwork/iTunesArtwork
    2) inGeek Tools, I created an entry including this shell command : osascript /Users/MyAccount Name/Pictures/iTunes Artwork/iTunesArtwork.scpt
    3) in GeekTool, I created another entry including this picture commande : file:///Users/MyAccount Name/Pictures/iTunes Artwork/albumArt.tif
    Each GeekTool command have a 10 sec. refresh time.

    When I do nothing… nothing happens ;-)

    When I run the script manually (using Script Editor)… the playing album artwork displays correctly, but never changes unless I run the script manually.

    I do not see where the bug can be… :-/

    Francois

  49. Gravatar Icon 49 Nick Young May 14th, 2007 at 1:15 am

    Francois,

    I can only think of one thing that could be your problem. You said that you named the script iTunesArtwork in step one. But in step two when you call the script you are referencing iTunesArtwork.scpt. The two need to match. Either make them both iTunesArtwork or make them both iTunesArtwork.scpt . Hopefully that will fix your problem :)

  50. Gravatar Icon 50 Francois May 14th, 2007 at 8:05 am

    As usual, trivial bugs never appear first ! I added the right extension and all works fine.

    Thanks !

    Francois

  51. Gravatar Icon 51 Joer May 22nd, 2007 at 7:05 am

    Okay I think geek tool is def hogging my cpu on the macbook.
    If you have any info on beginners shell and script usage I would appreciate it.

    BTW your desktop looks pretty awesome.

  52. Gravatar Icon 52 Jon F Jul 20th, 2007 at 1:39 pm

    Your Ethernet And Airport IP Addresses Geek Tool script is exactly what I’m looking for, but I just can’t get it to work. I’m very inexperienced with Terminal don’t know what I’m doing wrong. Perhaps you could send me a detailed step-by-step? I don’t even know if I created the ipaddresses.bash file correctly.
    The Uptime and Memory/CPU usage tips are fantastic, too.

  53. Gravatar Icon 53 Paul Zovighian Jul 20th, 2007 at 9:18 pm

    Yea! I’m having the same problem! After trying different things with it, I managed to get ‘Airport’ but it didn’t display ethernet nor any ip addresses, it would be good if u could send a step by step for it to my email, or on the comment board.

    Also the display info iTunes shell is kinda funky– When I do the script on the script editor, and save it as a ‘.scpt’ but as an application format, it tells me I have to change it to .app, or make it .scpt.app, I’m definitely sure I’m doing something weird on that.

    Anyways, when you’re not busy, it would be nice to have some light shed into my direction :D

  54. Gravatar Icon 54 fr33Z3r Sep 25th, 2007 at 10:11 pm

    This is my very first post to any online blog. I am new to mac and scripting. I am really impressed with the Geektool considering the possibilities it has. I used the network script but was not happy with the lengthy output so went through the script understanding wat was happening, then thought of creating my first script with trial and error method. This is my script:
    ====================================================================
    myen0=`ifconfig en0 | grep “inet ” | grep -v 127.0.0.1 | awk ‘{print $2}’`
    myen1=`ifconfig en1 | grep “inet ” | grep -v 127.0.0.1 | awk ‘{print $2}’`
    myvar1=`system_profiler SPAirPortDataType | grep -e “Current Wireless Network:” | awk ‘{print $4}’`
    myvar2=`system_profiler SPAirPortDataType | grep -e “Wireless Channel:” | awk ‘{print $3}’`
    myvar3=`system_profiler SPNetworkDataType | grep -e “Router: ” | awk ‘{print $2}’`
    ext1=`curl -s http://checkip.dyndns.org/ | sed ’s/[a-zA-Z/ :]//g’`
    if [ “$myen0″ != “” ]
    then
    if [ “$myen1″ != “” ]
    then
    echo “Connection : Ethernet|Airport [$myvar1 : $myvar2]”
    echo “IP Address : $myen0|$myen1″
    else
    echo “Connection : Ethernet”
    echo “IP Address : $myen0″
    fi
    else
    if [ “$myen1″ != “” ]
    then
    echo “Connection : Airport [$myvar1 : $myvar2]”
    echo “IP Address : $myen1″
    else
    echo “Connection : No Network”
    echo “IP Address : No Network”
    fi
    fi
    echo “Router : $myvar3″
    echo “External : $ext1″
    ====================================================================
    I would really like to know your views about the script and also need your help as i am not able to achieve the expected output considering when both the interfaces (Ethernet & Airport) are connected. Also how toscript for the scenario where both the interfaces are connected to different networks - 2 Local IPs, 2 Routers and 2 WAN IPs.

    Next I would like to find out the ISP name using the WAN IP.

    Sorry for the long post, i am really excited using the Geektool.

    Thanks

  55. Gravatar Icon 55 Patrick Thompson Oct 9th, 2007 at 7:44 am

    I’m having a problem with the album art as Francois was above. I made sure everything matches and it’s all typed in correctly, but for the life of me i cannot get the script to automatically update. What am I missing?

  56. Gravatar Icon 56 Drew Oct 18th, 2007 at 8:41 am

    Hey, glad to see others using geektool. Isn’t it great?

    I recently migrated my main PC to Linux and have been trying to set up a geektool-esque look on my computer, but I am having trouble:(

    Regardless, here is what my geektool-ed mac (laptop) looks like. Image is compressed a bit, but you can get the general idea: http://img137.imageshack.us/img137/3…screen1bq9.gif

  57. Gravatar Icon 57 Drew Oct 18th, 2007 at 8:42 am
  58. Gravatar Icon 58 keneil Nov 16th, 2007 at 9:42 am

    its the greatest thing i have ever seen

  59. Gravatar Icon 59 Zeyad Zainal Nov 19th, 2007 at 9:31 pm

    Great article! One problem though, I copied/pasted the script for the Uptime, CPU Usage Shell, but all it shows me is Uptime and RAM. CPU does not appear on the third line. Help :(

    Also can you explain to me what the number after the comma on the first line means? (eg, UPTIME: 12 mins, 1) What does that 1 stand for? Days?

  60. Gravatar Icon 60 Mike Dec 4th, 2007 at 9:58 pm

    Hey, i keep copying and pasting the itunesInfo.scpt into “Script Editor” and it gives me an error

    expected end of line, etc. but found “)”.

    This is probably a real easy fix, but i must confess. im at a loss. Any ideas? Thanks alot. :)

  61. Gravatar Icon 61 Eric Dec 6th, 2007 at 1:46 pm

    Hey, this thing is great, thanks for all the tips. I have one question, is there anyway to add the track time into the shell? It’d be really helpful to know how long the song is or how far I am and such.

  62. Gravatar Icon 62 Ed Dec 10th, 2007 at 6:14 pm

    Hey,

    Great entry and follow up. Got a tip and a question…

    Tip: you can get updating weather images from BBC weather by cutting the image address from the 5 day forecast and adding as a picture on GeekTool.

    Question: anyone got a nice way to display RSS/Atom feeds with this?

    Ed

  63. Gravatar Icon 63 Ed Dec 10th, 2007 at 7:30 pm

    Dunnit:

    curl –silent “http://www.guardian.co.uk/rss” | grep -E ‘(title>|description>)’ | \

    sed -n ‘4,$p’ | \

    sed -e ’s///’ -e ’s///’ -e ’s///’ -e ’s///’ | \

    head -n 10

    Save as “rss-feed.sh” and run from GeekTool.

    :-)

  64. Gravatar Icon 64 Ed Dec 13th, 2007 at 6:22 am

    Oops, my sed commands got messed up there because they had tags in …

    curl –silent “http://www.guardian.co.uk/rss” | grep -E ‘(title>|description>)’ | \

    sed -n ‘4,$p’ | \

    sed -e ’s/<title>/ - /’ -e ’s/<\/title>//’ -e ’s/<description>//’ -e ’s/<\/description>//’ | \

    head -n 14

    Hope that works …

  65. Gravatar Icon 65 Dave Jan 17th, 2008 at 8:05 am

    I’m using Geektool and loving it - however, my system.log has moved over and geektool isn’t updating to the new log, even when I force refresh. The final lines says ‘logfile turned over’ and the new system.log isn’t displaying. I have enter the system prefs, delete the existing file path reference, force refresh, then add in the system.log file path.

    Surely there’s an easier way which I just don’t know how to do?

  66. Gravatar Icon 66 evilrho Feb 6th, 2008 at 12:08 pm

    Hi everyone,

    Just came across this page and found it really useful. But, like lots of other folks here, I had some issues getting some of the scripts to work. One of the problems may be the following:

    If you’re trying to run a script in a folder name with a space in it, you need to add the backslash. So for me, my home director is ‘mdrew’ and if I’m trying to run a script in:

    /Users/mdrew/Pictures/iTunes Artwork/ScriptName.scpt
    I need to enter the shell command as:

    osascript /Users/mdrew/Pictures/iTunes\ Artwork/ScriptName.scpt
    This is a common issue with Linux/Unix-based systems. It may be obvious to most but I bet not to all. Hope that helped.

    Oh, one question. The iTunesInfo script works well when I’m playing regular stuff from my library, but if I’m listening to a streamed station via iTunes I just get an incorrect track listing and nothing for Artist or Album. (Although they appear on iTunes correctly.) Any thoughts?

    -

    -

  67. Gravatar Icon 67 BobbyW Feb 11th, 2008 at 8:53 pm

    Does top keep running like it would in terminal without any options, updating continuously? Or is it grabbing the information at the interval set in Geektool and quitting until the next interval?

    Also - I’m not getting the CPU info you have in your Uptime entry. Any idea why that might be?

  68. Gravatar Icon 68 Alex Feb 20th, 2008 at 1:56 pm

    Here’s an improvement to the network connectivity script posted above..

    The output looks something more like this:

    
    ETHERNET IP   : INACTIVE
    AIRPORT  STATUS: CONNECTED
             SSID : linksys
             RATE : 54 Mb/s
    AIRPORT  IP    : 10.0.9.60
    

    I use the parsed output of the command-line airport status tool. It’s a handy doodad, and located at: /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

    Here’s my perl script..

    
    #!/usr/bin/perl                                                                                                         
    # a little script to get your network status                                                                            
    
    $en0_info = `ifconfig en0 | grep "inet" | grep -v 127.0.0.1`;
    $en1_info = `ifconfig en1 | grep "inet" | grep -v 127.0.0.1`;
    $airport_info = `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I`;
    
    if($en0_info)
    {
        $en0_info =~ /inet (.*) netmask/s;
        $output .= "ETHERNET IP   : $1\n";
    
    }
    else
    { $output .= "ETHERNET IP   : INACTIVE\n";}
    
    
    if($en1_info)
    {
        $en1_info =~ /inet (.*) netmask/s;
        $en1_info = $1;
        $airport_info =~ /lastTxRate: (\d )/s;
        $airport_rate = $1;
        $airport_info =~ /BSSID(.*?)SSID: (.*?)\n/s;
        $airport_SSID = $2;
        $output .= "AIRPORT  STATUS: CONNECTED\n";
        $output .= "         SSID : $airport_SSID\n";
        $output .= "         RATE : $airport_rate Mb/s\n";
        $output .= "AIRPORT  IP    : $en1_info\n";
    }
    else
    { $output .= "AIRPORT  STATUS: INACTIVE\n";}
    
    print "$output";
    

  69. Gravatar Icon 69 jacob Feb 20th, 2008 at 7:17 pm

    Alex, your perl script output looks like this on my computer.

    ETHERNET IP : INACTIVE
    AIRPORT STATUS: CONNECTED
    SSID : Lothlorien
    RATE : 172.16.1.8 Mb/s
    AIRPORT IP : 172.16.1.8

  70. Gravatar Icon 70 Andy Mar 12th, 2008 at 7:16 pm

    Hi, your external ip address script has < in it instead of an angular bracket. Here’s the correct version (I hope it does not get messed up by your blog engine.

    echo “External :” `curl –silent http://checkip.dyndns.org | awk ‘{print $6}’ | cut -f 1 -d “

  71. Gravatar Icon 71 Joe Mar 27th, 2008 at 3:14 pm

    Newbie question: for Alex’s new network connectivity command is it simple enough to cut and paste his script into a text file called network.sh or do I need to do something else to it?

    When I run it as a shell command it gives me an error “: No such file or directory.

    I’m not sure what else needs to be done. Thanks

  72. Gravatar Icon 72 William Apr 15th, 2008 at 11:50 am

    If you’d like the rating of the current track to be displayed, the rating value is stored as parts out of 100. Keeping to the 5 star iTunes system, simply divide by 25.
    :
    set trackRating to the (rating of trackID) / 25

  73. Gravatar Icon 73 Daren Dec 12th, 2008 at 3:45 pm

    So, I love this, its awesome. Here’s the one problem I’m having: getting the album artwork to work. When i try to run the apple script this is what i get:

    AppleScript Error

    Folder xxxxx x xxxxx
    HD:Users:xxxxxxxxxx:Pictures:iTunes Artwork:From
    iTunes:albumArt.pict wasn’t found.

    Any ideas? I’m really new to all this, but understand enough to get in trouble I guess…

    I’m running iTunes 8.0.2 and OSX Version 10.5.5 in case that matters. It just seems like things aren’t where they are supposed to be and the script is therefore trying to reference something that “isn’t there”…

    Thanks in advance for any help you can offer.

  74. Gravatar Icon 74 CATWEB Jan 20th, 2009 at 9:46 pm

    is there any way I could limit the output of the trackname to, say, 50 characters in the itunesinfo.scpt. For example, when the title of a song is very long, the output takes over my screen and makes it look odd. I would like to have control on the number of characters output by the script. Thanks in advance

  75. Gravatar Icon 75 Craig Williams Feb 3rd, 2009 at 10:32 am

    CATWEB,
    :
    Try this.
    :
    set trackID to the current track
    set trackName to the name of trackID
    set trackName to text 1 thru 50 of trackName

  76. Gravatar Icon 76 A Feb 10th, 2009 at 9:54 am

    Hello, how can i get the battery on the desktop like in the screenshots?

  77. Gravatar Icon 77 Ben Feb 14th, 2009 at 10:24 pm

    I know this is an ancient article, but in case you and/or anyone else are still interested in a way to get the full wireless network name instead of just the first word, you can replace the “awk” statement with this:

    sed ’s/.*: //’

    So, the full line in your script would become:

    myvar1=`system_profiler SPAirPortDataType | grep -e “Current Wireless Network:” | sed ’s/.*: //’`

  78. Gravatar Icon 78 schegi Feb 24th, 2009 at 5:22 pm

    Here is a way to display the temperature in geektools. Its a little bit tricky and be careful u can harm your mac with the tools you use.

    First you have to download the smcFanControl e.g here:
    http://homepage.mac.com/holtmann/eidac/software/smcfancontrol2/index.html

    Next to do, install it and then select it in the finder. Then ctrl-klick and choose “ShowPackageContent”. In there under Content/Resources you will find a program called smc. With this little bash program it is possible to read out fanspeeds, sensor-temps and all the other sensors.

    !!!!!Be Carefull. You can also write to the smc with this program. It will not be so healty for your macbook if you set the max fanspeed to 0!!!!!

    A little readme for the program you can find under Content/Resources/sources/smc-0.01/README
    I just copied smc to my /usr/local/bin so i can use it easy from everywhere even from geektools.

    Have Fun

    Stefan

  79. Gravatar Icon 79 Ming Feb 27th, 2009 at 3:16 am

    Daren, try creating the folders that could not be found using the Finder. It works on mine.

  80. Gravatar Icon 80 schegi Feb 27th, 2009 at 2:46 pm

    Here is a little script to get the temperatures out of the 2Byte registers, make decimals from the hexas and remap the values. The remapping formulars i get out of the smcfancontrol-sources maybe someone would check the korrektness.

    #!/bin/bash
    #
    # TP Probe IntelMac
    #
    # Check os

    #Temperatur CPU Diode
    TCD1=$(smc -k TC0D -r | awk ‘{print $4}’ | tr “[:lower:]” “[:upper:]” )
    TCD2=$(smc -k TC0D -r | awk ‘{print substr($5,1,2)}’ | tr “[:lower:]” “[:upper:]”)
    tmp1=$(echo “ibase=16; $TCD1″ | bc)
    tmp2=$(echo “ibase=16; $TCD2″ | bc)
    CPUDT=$(echo “scale=5;($tmp1*256 tmp2)/(4*64)”|bc)
    echo “Temperatur CPU Diode = $CPUDT”

    #Temperatur CPU Pin
    TCP1=$(smc -k TC0P -r | awk ‘{print $4}’ | tr “[:lower:]” “[:upper:]”)
    TCP2=$(smc -k TC0P -r | awk ‘{print substr($5,1,2)}’ | tr “[:lower:]” “[:upper:]”)
    tmp1=$(echo “ibase=16; $TCP1″ | bc)
    tmp2=$(echo “ibase=16; $TCP2″ | bc)
    CPUPT=$(echo “scale=5; ($tmp1*256 tmp2)/(4*64)”|bc)
    echo “Temperatur CPU Pin = $CPUPT”

    #Temperatur GPU Diode
    TGD1=$(smc -k TG0D -r | awk ‘{print $4}’ | tr “[:lower:]” “[:upper:]”)
    TGD2=$(smc -k TG0D -r | awk ‘{print substr($5,1,2)}’| tr “[:lower:]” “[:upper:]”)
    tmp1=$(echo “ibase=16; $TGD1″ | bc)
    tmp2=$(echo “ibase=16; $TGD2″ | bc)
    GPUDT=$(echo “scale=5; ($tmp1*256 tmp2)/(4*64)”|bc)
    echo “Temperatur GPU Diode = $GPUDT”

    #Temperatur GPU Heatsink
    TGH1=$(smc -k TG0H -r | awk ‘{print $4}’ | tr “[:lower:]” “[:upper:]”)
    TGH2=$(smc -k TG0H -r | awk ‘{print substr($5,1,2)}’ | tr “[:lower:]” “[:upper:]”)
    tmp1=$(echo “ibase=16; $TGH1″ | bc)
    tmp2=$(echo “ibase=16; $TGH2″ | bc)
    GPUHT=$(echo “scale=5; ($tmp1*256 tmp2)/(4*64)”|bc)
    echo “Temperatur GPU HeatSink = $GPUHT”

    #Temperatur Heatsink 1
    TH11=$(smc -k Th0H -r | awk ‘{print $4}’ | tr “[:lower:]” “[:upper:]”)
    TH12=$(smc -k Th0H -r | awk ‘{print substr($5,1,2)}’ | tr “[:lower:]” “[:upper:]”)
    tmp1=$(echo “ibase=16; $TH11″ | bc)
    tmp2=$(echo “ibase=16; $TH12″ | bc)
    HS1T=$(echo “scale=3; ($tmp1*256 tmp2)/(4*64)” | bc)
    echo “Temperatur HeatSink 1 = $HS1T”

    #Temperatur Heatsink 2
    TH21=$(smc -k Th1H -r | awk ‘{print $4}’ | tr “[:lower:]” “[:upper:]”)
    TH22=$(smc -k Th1H -r | awk ‘{print substr($5,1,2)}’ | tr “[:lower:]” “[:upper:]”)
    tmp1=$(echo “ibase=16; $TH21″ | bc)
    tmp2=$(echo “ibase=16; $TH22″ | bc)
    HS2T=$(echo “scale=3; ($tmp1*256 tmp2)/(4*64)” | bc)
    echo “Temperatur HeatSink 2 = $HS2T”

  81. Gravatar Icon 81 fogboy Mar 18th, 2009 at 7:20 pm

    i liked the calendar output. i was able to get the same result with just:

    cal -m $(date %mm)

    this is nice, it’s the current month. BUT, i’ve tried numerous permutations, but can’t seem to get the correct syntax for the PREVIOUS and NEXT months.

    anyone know how to do that?

    thanks!

  82. Gravatar Icon 82 Chris Mar 25th, 2009 at 7:53 am

    Great site! Thanks for all the info! Quick question - can you point me in the direction to install “NR” that is mentioned in the uptime code?

    Thanks!

  83. Gravatar Icon 83 Kevin Casey Mar 28th, 2009 at 6:48 am

    @Ben - thanks for the sed trick. I’m not too familiar with it, and was going to suggest augmenting the awk command:

    system_profiler SPAirPortDataType | grep -e "Current Wireless Network:" | awk '{print "Airport: " $4 " " $5 " " $6 " " $7 " " $8}'

    The problem with awk is that it still only shows the first five words of the network name, where it looks like sed won’t care how many words are in the name.

  84. Gravatar Icon 84 Eugene Apr 5th, 2009 at 3:14 am

    Nick,

    Referring to the iTunesInfo script, the last few characters end up with symbols that indicate that my Mac can’t translate them into Unicode characters or whatever. Could you tell me what those last characters are? (Describing them seems best)

    With best regards,
    Eugene Ho

  85. Gravatar Icon 85 Sam Apr 17th, 2009 at 6:56 pm

    anyone have any clues on how to get a clock up there? I know there’s one right up on my menu bar, but it just fits so well with the rest of the text on my desktop.

    thanks in advance, and thanks for all the other cool shells.

  86. Gravatar Icon 86 tacitus May 1st, 2009 at 9:00 am

    Because you mentioned that only the first part off the network name was displayed I made a little change. (notice the “$5″ on the third line) This works for me but I can’t promise it(adding $6$7 etc.) will work if the network exists of more than 2 parts.

    1. #!/bin/sh
    2. myvar1=`system_profiler SPAirPortDataType | grep -e “Current Wireless
    3. Network:” | awk ‘{print $4$5}’`
    4. myvar2=`system_profiler SPAirPortDataType | grep -e “Wireless Channel:” | 5. awk ‘{print $3}’`
    6.
    7. echo “Airport : $myvar1 - $myvar2″

    Also as an unrelated sidenote I wrote a little python script to show the calendar. (just a matter of preference)

  87. Gravatar Icon 87 fogboy May 6th, 2009 at 9:30 pm

    answer found! a couple posters on apple discussions took stabs at it, but BobHarris got it right:

    cal $(date -v -1m ” %m %Y”) # Last month
    cal $(date ” %m %Y”) # This month
    cal $(date -v 1m ” %m %Y”) # Next month

    (when putting it in geektool, lose the comment parts, the #, etc)

    full discussion here:

    http://discussions.apple.com/thread.jspa?messageID=9431074#9431074

  88. Gravatar Icon 88 Ben May 29th, 2009 at 8:47 am

    Hey there!
    Got several problems with the itunes script…
    First thing is it doesnt work out of geektool, which is the biggest problem :)
    Used this command: osascript /Users/ben/Dokumente/Geektool/it.scpt | \
    iconv -f utf-8 -t ucs-2-internal
    Doesnt work without the extending reformat things either. Saving the script as an app just adds .app to the filename, if I add that it doesnt give answers either.
    I added a star system myself:

    Script Start —>
    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 stars to the (rating of trackID)
    if stars = 20 then
    set stars to 1
    end if
    if stars = 40 then
    set stars to 2
    end if
    if stars = 60 then
    set stars to 3
    end if
    if stars = 80 then
    set stars to 4
    end if
    if stars = 100 then
    set stars to 5
    end if
    0
    set totalData to “Track : ” & trackName & trackPaused & ”
    Artist : ” & artistName & ”
    Album : ” & albumName & ”
    Stars : ” & stars
    return totalData
    end tell

  89. Gravatar Icon 89 Ben May 29th, 2009 at 8:52 am

    okay, works, just one problem still exists:
    when i do rating / 20 it gives out a float number like 3,0. How can i change it to integer ?

    Cause now i do this if 20 then stuff which makes the code long^^

  90. Gravatar Icon 90 Ben May 29th, 2009 at 9:07 am

    Delete the previous posts, it’s okay… just got this here not to work:

    set trackName to text 1 thru 50 of trackName

    It is supposed to limit my trackname to reduce it to 50 letters… but script editor gives back “„text 1 thru 50 of “Songtitle”“ kann nicht gelesen werden.”
    Means: “Text 1 thru 50 of “songtitle”" can’t be read.

    Solution? :(

  91. Gravatar Icon 91 benjamin sanders May 29th, 2009 at 11:13 am

    in regards to the above on “Current Wireless Network”, updated script below to display the FULL name of the wireless network. basically changing the “awk” command to “cut” as below:

    #!/bin/sh
    myvar1=`system_profiler SPAirPortDataType | grep -e “Current Wireless Network:” | cut -d: -f 2`
    myvar2=`system_profiler SPAirPortDataType | grep -e “Wireless Channel:” | cut -d: -f 2`

    echo “Airport : $myvar1 - $myvar2″

  92. Gravatar Icon 92 Frank May 30th, 2009 at 1:50 am

    hey i am just getting into scripting and i was wondering if anyone has a script to put ur ical events for the day on ur desktop?

  93. Gravatar Icon 93 Alex Jun 3rd, 2009 at 12:36 pm

    There is an app called Little Snitch that gives you a nice little graph of network traffic in the menubar, offers the option to prevent any application you wish from connecting to the internet without your knowledge, and block incoming connections. It’s even growl compatible.

    Also, there is a free application called Bowtie which displays iTunes track info on your desktop without it disappearing. It also has a dozen free customizable themes that can be modified to suit anyone’s needs.

    Hope this helps :)

  94. Gravatar Icon 94 Carl Jun 6th, 2009 at 5:18 pm

    I use GeekTool to display an RSS feed on my desktop. How can I get quotation marks and apostrophes to display properly? Whenever they show up I only see their HTML codes (i.e. ampersand#39semicolon and ampersandquot, etc.) I guess it’s because the feed uses curved quotes and not straight ones, is there any way to fix that on my end?

  95. Gravatar Icon 95 czud Jun 12th, 2009 at 12:41 pm

    This is very picky of me but I’m trying to reformat the uptime to read: 2d 4h 6m

    At the moment I’m using :
    uptime | awk ‘{print “Uptime: ” $3 “d ” $5 }’ | sed -e ’s/.$//g’
    which gives
    Uptime: 2d 4:06
    The sed obviously takes care of the comma that usually appears at the end of this expression but I’m not too familiar with awk and I guess I’m trying to reformat $5 somehow. Any suggestions would be greatly appreciated.

  96. Gravatar Icon 96 Squid Jun 15th, 2009 at 9:43 pm

    Hey, I have a better solution for the airport:

    /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I

    which gives you either this:

    commQuality: ##
    rawQuality: ##
    avgSignalLevel: -##
    avgNoiseLevel: -##
    linkStatus:
    portType:
    lastTxRate: ##
    maxRate: ##
    lastAssocStatus: #
    BSSID: xx:xx:xx:xx:xx:xx
    SSID: xxxxx
    Security: WPA

    or this:

    Airport: Off

    That’s a rather long path to type, so I created a symlink to the airport command in usr/sbin:

    sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

    This is the script I use for GeekTool:

    #myvar1=`airport -I | grep ” SSID\|AirPort” | awk ‘{print $1, $2}’`
    #myvar2=`airport -I | grep channel | awk ‘{print “Channel:”, $2″,”}’`
    #myvar3=`airport -I | grep agrCtlRSSI | awk ‘{print “Signal:”, $2″,”}’ `
    #myvar4=`ifconfig en1 | grep “inet ” | awk ‘{print “IP:”, $2}’`
    #echo “$myvar1 $myvar2 $myvar3 $myvar4″

    Which gives me:

    SSID: linksys Channel: 1, Signal: -40, IP: 192.168.1.100

    or:

    AirPort: Off

    As a note, the channel and signal commands are for Leopard. The channel command doesn’t work, and the signal one should grep avgSignalLevel instead of agrCtlRSSI. Also, the above should be saved to a shell script, which should then be called from GeekTool.

  97. Gravatar Icon 97 Plop Jul 3rd, 2009 at 3:25 pm

    Hey,
    Firstly, thanks for this great article. Really usefull.
    Configuring that app is not really easy. :)

    Secondly, I was wondering if you could share the desktop image shown on your screenshot.
    I really like it, but I don’t know where I could get it.
    Could you tell me where you got it from, or upload it?
    (I hope it’s available in 1900×1200 format)

  98. Gravatar Icon 98 Kirby Jul 16th, 2009 at 5:26 pm

    I found the problem with the Rate output in F33z3r’s PERL script. Where he says “$airport_info =~ /lastTxRate: (\d )/s” it should say “$airport_info =~ /lastTxRate: (\d*)/s”. Now the script works fine.

  99. Gravatar Icon 99 mediapathic Aug 7th, 2009 at 1:47 am

    Hey, wanted to let you know, you inspired me to set up something similar, but I run mpd instead of itunes. So, my now playing script is:

    /opt/local/bin//mpc |head -n1

    Which, like everything about mpd vs itunes, is much simpler ;>

    Cheers, and thanks for the inspiring article!

  100. Gravatar Icon 100 Fabian Aug 26th, 2009 at 4:20 am

    Could anyone please help me with the itunes artwork script?

    my problem is that the script barks on the following line:

    set ArtworkFromiTunes to FromiTunesFolder & “albumArt.pict” as file specification

    it says it cannot convert from \”Mac:Users:fabian:Pictures:iTunes Artwork:From iTunes:albumArt.pict\” to type file specification.” number -1700 from “Mac:Users:fabian:Pictures:iTunes Artwork:From iTunes:albumArt.pict” to file specification

    if i remove the “to file specifiction” the .pict file is updated but alas without the converted tiff so i cannot view it.

    thanks

  101. Gravatar Icon 101 Glenn Sep 6th, 2009 at 9:07 pm

    For the Battery Capacity Stuff, try this one-liner:

    for str in DesignCapacity MaxCapacity CurrentCapacity;do ioreg -w0 -l|grep $str|/opt/local/bin/gawk -v var=$str ‘{print var ” = ” $NF}’;done

    I think the calendar entries are not quite right. They gave me three identical months. Try:

    cal $(date -v -1m ” %m %Y”); cal $(date ” %m %Y”); cal $(date -v 1m ” %m %Y”)

    The only difference seems to be the sign in %m

  102. Gravatar Icon 102 Wooden Brain Concepts Sep 23rd, 2009 at 8:00 am

    Thanks for some great tips.

    Forgive the plug, but I’ve included a clean, fast, easy to configure, implementation for iTunes artwork in OmniGrowl version 3.7.

    (It requires GeekTool 3 and neither needs to poll iTunes for track changes nor refresh GeekTool unless the track changes.)

    Included an iTunes GeekTool template for the new iTunes plugin that will display iTunes artwork and track info on the desktop with GeekTool 3 installed and some minimal configuration. (See Advanced Info.)
    Since OmniGrowl handles everything, this is a much better solution for GeekTool users than anything currently available (just try it).

  103. Gravatar Icon 103 djyle Oct 9th, 2009 at 1:37 pm

    I tried to improve the itunes script to fit what i needed, but i’m totally new to scripts, so maybe you’ll find a better way to write it.

    It works, as if, on my mac, displaying info od the current track, length and rating and the stream info if it’s an audio stream like an internet radio.

    here it is and what it looks like (http://img12.yfrog.com/img12/8824/capturedcran20091006232.png):

    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
    return “”
    end if
    if playerstate = stopped then
    return “”
    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 songLength to the time of trackID
    set myRating to round ((rating of current track) / 20)
    if myRating is 1 then
    set myRating to ” - ✭✩✩✩✩”
    else if myRating is 2 then
    set myRating to ” - ✭✭✩✩✩”
    else if myRating is 3 then
    set myRating to ” - ✭✭✭✩✩”
    else if myRating is 4 then
    set myRating to ” - ✭✭✭✭✩”
    else if myRating is 5 then
    set myRating to ” - ✭✭✭✭✭”
    else
    set myRating to ” - ✩✩✩✩✩”
    end if

    set theStream to the current stream title as text
    set ISstream to the size of trackID as text
    if theStream is not null then
    if theStream is not “missing value” then
    set totalData to ” ▶ ” & theStream & ” (” & trackName & “)” & myRating
    else
    if ISstream is not “missing value” then
    set totalData to ” ▶ ” & trackName & ” / ” & artistName & ” / ” & albumName & ” - ” & songLength & myRating
    else
    set totalData to ” ▶ ” & trackName & myRating
    end if
    end if
    else
    if ISstream is not “missing value” then
    set totalData to ” ▶ ” & trackName & ” / ” & artistName & ” / ” & albumName & ” - ” & songLength & myRating
    else
    set totalData to ” ▶ ” & trackName & myRating
    end if
    end if
    return totalData
    end tell

  104. Gravatar Icon 104 Aaron Dec 30th, 2009 at 5:48 pm

    Just wondering if you (Nick Young) are still using GeekTool and if you have had to make any changes with Snow Leopard or the latest beta release of GeekTool…I can use this from the GeekTool website and get lots of info, but not well organized:
    top -n43 -l2 -o-CPU > top.txt && tail -n52 top.txt If I use the command you listed I get nothing.
    Also, if I use the command for up time, ram and cpu usage I only see uptime and RAM so I’m assuming this is a SL thing?Thanks for any light you can shed…

  105. Gravatar Icon 105 Matt Jan 11th, 2010 at 6:50 pm

    We’re trying to build a community where people can share their GeekTool setups over at http://www.macosxtips.co.uk/geeklets

    People can download and contribute the “geeklet” files that GeekTool 3 now uses. It’s a great place if you are looking for some new scripts or if you want to share your cool new setup.

  106. Gravatar Icon 106 jonas Jan 20th, 2010 at 5:02 am

    I used the calendar shell, but would like Sundays to come at the end instead of the beginning, does anyone have a way to fix this?

  107. Gravatar Icon 107 Thomas Apr 30th, 2010 at 5:49 pm

    Anybody figure out how to get the name of the song on pandoraboy that is playing to display using geektools? I found one site, but couldn’t get her instructions to work and they were for using an older version of geektool, so I’m not sure if it was her instructions or the older version or just my inability (most likely) to follow her instructions properly. I find that too many offering advise assume everybody understands all the additional, unmentioned steps needed. I appreciate the fact you explained about needing to use terminal in some cases… I think that might be the case with the pandora fix I found, but too scared to “experiment” lol

  1. 1 Pimp Your Desktop « Pimp My Mac Pingback on Apr 11th, 2007 at 7:34 am
  2. 2 Make Your Dock Transparent With ClearDock at Keynote 2 Keynote Pingback on Apr 25th, 2007 at 2:44 am
  3. 3 links for 2007-05-16 » Graham English Social Networking Pingback on May 17th, 2007 at 2:27 pm
  4. 4 Infovore » links for 2007-10-30 Pingback on Oct 30th, 2007 at 3:20 pm
  5. 5 pseudotecnico:blog » [Mac Os X] GeekTool Pingback on Nov 1st, 2007 at 7:00 pm
  6. 6 dee’s blog - conky per osx: geektool Pingback on Nov 7th, 2007 at 10:49 am
  7. 7 My First Bit of Programming in a Long Long Time : Living the Liminal Pingback on Jan 6th, 2008 at 6:03 pm

Leave a Comment


Please Note: If this is your first time commenting, your comment is subject to moderation. There is no need to resubmit your comment.




heat pumps and best buy pirodr! 666

Close
E-mail It
Socialized through Gregarious 39