Wednesday, June 13, 2007

Some Mac Geekery

2 years. That's how long I've been a Mac user. Serenity, my trusty iBook, has been serving me well considering that she's hardly ever been turned off since the first day I pressed the power button.

Only recently I've started getting the urge to indulge the inner geek in me, and here's what I've got to show - my desktop, running GeekTool.

GeekTool is probably mainly used to monitor your system because it allows you to display unix commands output onto your desktop. It also lets you display contents of text files and images. Pretty geeky looking, but it's really useful for me.

Let me guide you through my desktop. On the top right corner, I display the date and time. Previously I displayed the date and time on the menu bar like everyone else, but on a 12-inch notebook, screen area is precious. Removing the date and time from the menu bar and putting them on the desktop freed up more space on my menu bar, making it less cluttered.

Shell Command to display the date:
date "+%a %b %d, %I:%M %p"


Then on the top center portion of the screen displays the currently playing song on iTunes. Normally I have iTunes minimised when I'm listening to music. So it's pretty useful for me to check what song's playing, and to check if I've paused iTunes before I remove my headphone jack in the office. Achieving this on GeekTool is a little more complicated, but if I can do it, so can you.

Save the script below into a directory of your choice, eg ~boysbytes/Documents/GeekTool_iTunes.scpt

Enter this script into Script Editor.
tell application "System Events"
set powerCheck to ((application processes whose (name is equal to "iTunes")) count)
if powerCheck = 0 then
return "iTunes not running"
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 artistName & " - '" & trackName & "' on " & albumName & trackPaused
return totalData
end tell
And in GeekTool, enter this Shell Command:
osascript /Users/boysbytes/Documents/GeekTool_iTunes.scpt
Still with me? Next up is my TO DO list. This is simply a text file todo.txt that I put into my Documents folder. Then I tell GeekTool to poll this file every few minutes.

The Shell Command to display my todo.txt.
cat ~boysbytes/Documents/todo.txt
The same for the list of TV shows that I follow.

And the last part at the bottom of the screen shows the 10 running processes on Serenity. It's not really useful for me, but sometimes I like to see what application is chewing up my CPU cycles.

Shell Command to display top 10 processes, their CPU and memory utilisation.
top -FR -o cpu -n 10 -l 2 | tail -11
Remember! Don't set your polling interval too frequently, or it will tax your system. Give a reasonable frequency. In my case, I update my Date and Time every minute, my todo.txt every 5 minutes, iTunes every 30 seconds, and refresh my top 10 processes every 30 seconds.

I got all the Shell Commands and scripts from Lifehacker and other internet resources that I forget. But do a Google and explore for yourself.

No comments: