April 9, 2010

High on GEEKdom

Sorry if I've been 'absent' lately away from my weekly posts (here and also on all my other websites). My only excuse is I recently fell down the 'rabbit hole' just like Alice. Instead of 'Wonderland', I call it 'GEEKdom'.

I can't even tell you how I fell in but I do know things have been a little stressed at work. You know, being pulled in way too many directions, helping others get their work done while mine is just sitting there gathering dust. Anyway, at some point, while escaping through the 'rabbit hole' I call the internet, I found a thing called GeekTool. I won't explain much how it works, but it takes a Mac desktop to a whole new level of visual information.

For example, here's my first attempt at sprucing up the ol'desktop. I know, working at a Buddhist center does seem to make one focused on Buddha.


GeekTool allows you to draw dynamic things on the desktop. For example, it gets the time and creates an image on the desktop. I can set how often it changes - for the time, it changes every 60 seconds. The temperature comes from a Yahoo Weather feed and GeekTool checks it every five minutes (or 300 second). The calendar at the top is another program called DateLine and you can alter the fonts and colors, even the width on the free version.

But hey, this desktop theme really didn't reflect my mood these days. Plus it still was pretty limiting creative-wise. So, I started over and this is what I have now. Yippie! I was even able to do a few things no one had thought of yet (and that's saying something when you consider that the 'GeekTool' thread on MacRumors has almost 2000 entries).

So, here's my set up. And for those of you who might fall down 'this rabbit hole', I'll put the code here too.

(click picture for more detail)

First, I use MacFreePOPs to pull in my email from a Yahoo account - that way I can at least read all my email in Mail. Plus, it comes in handy for my mail Geeklet below.

Okay, now for GeekTool:

Time
Probably the easiest thing to do. Go here or here for more time-date-day codes.
date +%l:%M

Current Weather Conditions
(MGXX0003 is the location code for Ulaanbaatar Mongolia)
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=MGXX0003&amp;u=f" | grep -E '(Current Conditions:|F<br)' -e="" conditions:="" current="" s="" sed="" |=""><br \="" />//' -e 's/<b>//' -e 's/&lt;\/b&gt;//' -e 's/<br \="" />//' -e 's/<description>//' -e 's/&lt;\/description&gt;//' -e 's/ F/°F/' | tail -n1

Calendar
My first desktop used DateLine but I want something more flexible, to go with my other design elements. So, I found this but wish there was some way to highlight the 'current' day instead of just replacing it with two dots.
echo `cal` | sed s'/Su Mo Tu We Th Fr Sa//g' | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/././g') /"

Email / Zen Quotes - Found an Applescript that pulls info from Mail and then I use the script to post that information in the center of my desktop. Almost like the guy is yelling it out to me. But what happens if there isn't any mail? I figured out how to then call up ZenQuotes and post them when there was no mail. As far as I could tell, no one has done this before.
osascript /Users/Jim/Documents/Scripts/checkmail.scpt

And here's my Applescript:
set newline to ASCII character 10
tell application "System Events" to set iCalIsRunning to (name of processes) contains "Mail"
set finalText to ""
if iCalIsRunning then
tell application id "com.apple.mail"
set unreadCount to (get unread count of inbox)
if unreadCount &gt; 0 then
set theMessages to (messages of inbox whose read status is false)
repeat with i from 1 to number of items in theMessages
set thisMessage to item i of theMessages
set fromMsg to (sender of thisMessage as string)
set subjMsg to (subject of thisMessage as string)
if subjMsg = "" then set subjMsg to "-- They're not sure what the subject is --"
else set subjMsg to newline &amp; " " &amp; subjMsg
end if
set finalText to finalText &amp; i &amp; ". " &amp; fromMsg &amp; subjMsg &amp; newline
end repeat
else set finalText to do shell script "curl -s http://www.dailyzen.com/ | sed -n '/&lt;\\!--Add Quote--&gt;/,/&lt;\\/TD&gt;/p'|sed -e 's/&lt;[^&gt;]*&gt;//g' |strings|fold -sw60"
end if
end tell
else
set finalText to "Oops, I forgot to turn on Mail"
end if
finalText

I can't even begin to tell you where I found all this stuff, but if you think you're a Mac-Geek too and feel like falling down the 'rabbit hole', here are a few links to get you started:

Download Geektools from here.
Weather, Temperature, Conditions, etc from MacThemes
Adding Email Notice from MacEnstein
More info about DailyZen in GeekTool is here.
The font I used is 'Just a Dream' from 1001Font.com
And you can find more Geeklets here
And best get help here at MacRumors:Forums-Your GeekTool Scripts
Wallpaper is from The-The album called 'Soul Mining' (1982)

Post Script: Well, after sleeping on it, I decided to make a few more changes. I thought 'Why should I use ZenQuotes online when I have a ton of quotes I've collected over the years. But how to get GeekTool to access them and display them write? Well, I wish I could say I found this somewhere on the net but after hours of searching, I sort of figured it out myself.

First, you a text file (filename.txt) and for this, one line equals a quote. I even put in a few blank lines so sometimes the screen is blank too. I could get more complicated like putting the author of the quote on a different line etc but I'll save that for another day. Here's a sample text file:

Thank god it's Friday! - Jim
I'll be back. - The Terminator
Now, we need to alter our Applescript to access the text file instead of ZenQuotes:

set newline to ASCII character 10
tell application "System Events" to set iCalIsRunning to (name of processes) contains "Mail"
set finalText to ""
if iCalIsRunning then
   tell application id "com.apple.mail"
      set unreadCount to (get unread count of inbox)
         if unreadCount > 0 then
         set theMessages to (messages of inbox whose read status is false)
         repeat with i from 1 to number of items in theMessages
            set thisMessage to item i of theMessages
            set fromMsg to (sender of thisMessage as string)
            set subjMsg to (subject of thisMessage as string)
            if subjMsg = "" then
               set subjMsg to "-- They're not sure what the subject is --"
            else
               set subjMsg to newline & " " & subjMsg
            end if
            set finalText to finalText & i & ". " & fromMsg & subjMsg & newline
         end repeat
      else
         set quoteFile to "untitled:Users:Jim:Documents:Scripts:quotes.txt" as alias
         open for access quoteFile
         set quoteList to every paragraph of (read quoteFile)
         set list_count to the count of quoteList
         set pick to random number from 1 to list_count
         set finalText to item pick of quoteList as string
         close access quoteFile
      end if
   end tell
else
   set finalText to "Oops, I forgot to turn on Mail"
end if
finalText
This works, but remember the quote text is all on one line and will run off the screen, so we need to wrap the text somehow. And by luck I figured out I can do that on the Geeklet by adding a bit that will fold the line:

osascript /Users/Jim/Documents/Scripts/checkmail2.scpt | fold -sw60
You can use this to display any sort of random information you already have. Or you can modify the code to do other things - the possibilities are only limited by your imagination.

Post Postscript: And also decided to add an iTunes Geeklet to tell me what is playing, whether it's from my music or streaming from the internet. You can find more information here.

Post Post Postscript: Decided that the icons, at least the ones visible on my desktop should also match my theme, so I found some already made at DeviantArt called "Sketchy Icons" found here. Modified the hard drive icon to be different: hard drive, usb drive, time machine drive. So, for now, I think my desktop is just about the way I want it. Here's one last screen shot.

(click picture for more detail)