Mail and iTunes for GeekTool

is a nifty little tool, that does something very simple yet powerfull: execute unix commands and show the output on your desktop. If you feed the little thing with the right code, it becomes sort of a tiny raw text dashboard. In addition to that it can monitor text files and pictures, so you can i.e. have your system log always on your desktop or set a link to a graph of your website stats which updates live.

I wrote two little pieces of AppleScript, one of which that just asks Mail periodically for unread messages and if there are any, returns the senders and subject lines. If there is no new mail, it says “No new mail”, and if you quit Mail it says “Mail not running”. The other one displays the current track track in iTunes, and can say “iTunes not running”, or “Stopped”.
This is what it looks like:
The top item is the Unix calendar which you get with the nice onelinercal | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/./#/g') /"

Below that I have the iTunes script, which you enable with the command

echo `/usr/bin/osascript ~/GeekTool/iTunes.scpt`

after you downloaded my script and put it in ~/GeekTool/iTunes.scpt that is.
Then download my Mail script, put it in ~/Library/Mail/Scripts and envoke it, using

osascript ~/Library/Mail/Scripts/NewItems.scpt

Be cautious with the refresh rates. If you set them too low, the drain on your system will be quite substantial. Good values are 3600s (once an hour) for the calender, 10s for iTunes, and 120s for Mail. Use with moderation.
This is another page with quite some nice examples and and intersting discussion thread.

Update: Better call the Mailscript with the command
osascript ~/Library/Mail/Scripts/NewItems.scpt | tr , "\n"
it will remove the comma at the end of every line.

I have rewritten the Mail script and it is much faster now and uses less CPU. This means that you can now set the refresh intervall shorter, Ohh, always use case for your ipod mini to use maximum day. Its just a safety tips


Leave a Reply

Your email address will not be published. Required fields are marked *