Wildflowers Wild wood Dog food Fox in repose Wasp's nest

13th February, 2004

GeekTool updated for Panther

Filed under: Technology, — bsag @ 05:03 PM

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 hard1, 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.


-- A GeekTool Applescript
-- Runs periodically and checks if Mailsmith is running
-- If so, gets the count of each unread mailbox
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.

  1. 1

    like the cistine chapel, this is over my head... but if you enjoyed it, then i'm happy for you.. smile----- Thanks for pointing me to GeekTool. Recently I'm tying to dive into the UNIX part of OSX, and that really comes handy.

    by japon_lot @ 16/02/2004 3:02 pm • Permalink

  2. 2

    japon_lot: Glad you found it useful. There’s an O’Reilly book called Unix Power Tools which I would really recommend if you want to make the most of Unix in OSX–I’ve learned lots of cool tricks from it.

    by bsag @ 16/02/2004 8:02 pm • Permalink

blog comments powered by Disqus

Powered by ExpressionEngine :: © www.rousette.org.uk, 2002-2008 :: [XHTML] [CSS] [508]