Archive | 3 September 2012

GeekTool: how to give your Mac’s desktop a bit of style [UPDATED]

Per la versione in italiano scendi a fine post.

Every Mac User know what the dashboard is. Though if you want to go even further than widgets, you can use GeekTool, a free utility that gives your desktop a bit of art. As an example, here’s my work after an hour:

Sounds good? Then let’s start! But before, I have to introduce GeekTool.
There are three type of geeklets (A geeklet can be a command):

  • File
  • Image
  • Shell (To use it, you have to copy and paste the commands in this tutorial in the “Command” field).

Plus, remember that you have to set a refresh time (in the “Refresh” field) for geeklets that requires to be updated on a regular basis like the clock, or not like a period.
Ok, now you’re ready to go!

A simple period

echo “write here”

It may be a stupid command, but I found it really helpful!


date “+%H:%M.%S”

A clock with hours, minutes and seconds.



Write this command if you want the clock plus the current date. If you want to have just a single value here are some:

Only the day:


Only the name of the day:


Only the month:



For the weather it’s a bit different.
First you have to put a shell geeklet with the following code (the link in the code have to be substituted with your own city and has to be from yahoo!).

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

It won’t happen anything, but that’s fine.
Now you can get the image. Now drag the “Image” geeklet on your desktop and write in the path:


If you want to get the live forecast but not as an Image, write this in a shell command. For the link it’s different: the following is a RSS link. You need to change the final code (ITXX0042) with the one of your city (you can find it just by clicking the RSS button and looking at the URL bar in the browser).

curl –silent “; | 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>//’ | tail -n1

RAM status

top -l 1 | awk ‘/PhysMem/ {print “[RAM]\t\tUsed: ” $8 ” Free: ” $10}’

With this you can get at a glance the current satus of the RAM.



maxcap=`ioreg -l | grep Capacity |awk ‘/MaxCapacity/{print $5}’`
curcap=`ioreg -l | grep Capacity |awk ‘/CurrentCapacity/{print $5}’`

curcap=`echo $curcap*1000|bc`
proc=`echo $curcap / $maxcap |bc`;

len=`echo ${#proc}`;


proc_num_len=`echo ${#proc_num}`;

if [ $proc_num_len == “3” ]; then
if [ $proc_num != “100” ]; then

echo “Battery: ” $proc_num.$proc_dec%

This can be used only on MacBooks.

Hard disk status

df -hl | grep ‘disk0s2’ | awk ‘{print “HD: ” $4″/”$2″ free (“$5″ used)”}’
Copy and paste it to get the status of the Hard Disk (free and used space).


uptime | awk ‘{print “[Uptime]\t\t” $3 ” ” $4 ” ” $5 }’ | sed -e ‘s/.$//g’

This controls for how long the Mac is on and the number of the logged in users.


curl –silent “$URL” |
sed -e :a -e ‘$!N;s/\n//;ta’ |
sed -e ‘s/<title>/\
<title>/g’ |
sed -e ‘s/<\/title>/<\/title>\
/g’ |
sed -e ‘s/<description>/\
<description>/g’ |
sed -e ‘s/<\/description>/<\/description>\
/g’ |
grep -E ‘(title>|description>)’ |
sed -n “$start,$”‘p’ |
sed -e ‘s/<title>//’ |
sed -e ‘s/<\/title>//’ |
sed -e ‘s/<description>/ /’ |
sed -e ‘s/<\/description>//’ |
sed -e ‘s/<!\[CDATA\[//g’ |
sed -e ‘s/\]\]>//g’ |
sed -e ‘s/</</g’ |
sed -e ‘s/>/>/g’ |
sed -e ‘s/<[^>]*>//g’ |
cut -c 1-$maxLength |
head -$end |
sed G |

With this, you can get live RSS in a geeklet (just change the link in the first line).

These are just  few of the commands that can be used, on the web you can find tons of the to better suit your needs.

Read More…

%d bloggers like this: