GeekTool updated for Panther

· technology ·

I've mentioned before that I'm an avid user of GeekTool, so I was disappointed to find that it was broken in Panther. I sorely missed the little bits of information that got written to my desktop, though my desktop is already pretty rich in information. I'm glad to say that GeekTool has now been updated for Panther and works fine.

I had a nice GeekTool entry which ran an Applescript written by Pete, which listed the mailboxes in Mailsmith with unread messages, and gave the unread message count. This was very handy as Mailsmith doesn't have a message count on the Dock icon like Mail. The only problem I had was that I would forget to disable the script when I wanted to logout or shutdown. As GeekTool runs the script at intervals, it would start up Mailsmith again, and therefore prevent me from logging out. Relying on me to remember to do anything is fraught with danger and disappointment, so I wanted to alter the script to check if Mailsmith was running before it did anything. That turned out to be inexplicably hard^1^, but I've managed to get it working now.

As Pete has taken down the page on which the original script used to reside, I've reproduced it below (with his permission and my additions) in case anyone else is interested. I'm sure that it would be reasonably easy to adapt it for other email clients, if they have decent scripting support.

global c
on run
  set c to " "
  set okflag to false
  tell application "System Events"
    if (get name of every process) contains "Mailsmith" ¬
           then set okflag to true
  end tell

  if okflag then
    tell application "Mailsmith"
      repeat with i from 1 to (count mailboxes)
  set obj to mailbox i
  my process_mailbox(obj)
   end repeat
 end tell
  else
 quit
  end if
 return c
end run
on process_mailbox(mbox)
  tell application "Mailsmith"
 set n to name of mbox
 if n is not "(spam)" then
   set mcount to (count (messages of mbox ¬
                 whose seen is false))
   if mcount > 0 then
    set c to c & (n & " " & mcount) & (ASCII character 10)
   end if
 end if
 repeat with i from 1 to (count mailboxes of mbox)
   set obj to mailbox i of mbox
   my process_mailbox(obj)
 end repeat
  end tell
end process_mailbox

Note: this character (¬) indicates a soft line wrap. That is, there should be no carriage return between the current and following line.

^1^ Perhaps not inexplicably — I'm not very good at Applescript.