Brent Simmons points us to an interview with the developer of Growl, a “global notification system for Mac OS X”. Essentially, other programs can send messages to Growl when they want to inform the user about something, and Growl displays it in a uniform, unobtrusive manner. The unobtrusiveness is where Growl stands out in comparison to Mac OS X’s built-in notification messages, like bouncing dock icons and dialog boxes.
From a developer’s standpoint, Growl is nice because it obviates the need to write your own customizable notification code. From a user’s standpoint, Growl is nice because it puts a lot of notification-related options in one place.
The other nice thing about Growl is that you can send messages from AppleScript or the command line. Shortly after downloading Growl, I threw together an AppleScript that sends a notification when Mailsmith receives new mail and a shell script that periodically checks Bloglines and sends a notification when there are new messages.
I want to emphasize that these are unpolished and experimental. They’re simple enough that I’m pretty confident nothing bad could happen if you were to use them, but proceed with caution.
There is currently no built-in support for Growl in Mailsmith, my current e-mail client of choice, but Mailsmith does allow you to run arbitrary scripts when new mail arrives or an error happens. Thus, we can take advantage of Growl’s AppleScript support.
I currently have the following script saved in Mailsmith’s “Action Scripts” folder (
~/Library/Application Support/Mailsmith Support/Action Scripts):
on run tell application "Mailsmith" set unreadCount to unread interesting end tell tell application "GrowlHelperApp" notify with title "Mailsmith" ¬ description ("New mail (" & unreadCount & " unread)") ¬ icon of application "Mailsmith" end tell end run on ErrorLogged(theMessage) tell application "Mailsmith" set msg to subject of theMessage end tell tell application "GrowlHelperApp" notify with title "Mailsmith" ¬ description msg ¬ icon of application "Mailsmith" end tell end ErrorLogged
Mailsmith is configured to call this script when new mail arrives and when errors occur. When new mail arrives, it calls the
run handler, which checks the number of “interesting” unread messages and sends that number to Growl. When an error occurs, Mailsmith calls
ErrorLogged, which gets the subject field of the error message and sends that to Growl.
Neither of these are as polished as I’d like. In particular, Mailsmith’s error messages aren’t very informative, and they undergo “quoted-printable” encoding somewhere between Mailsmith and the Growl notification display.
Bloglines, my current feed reader of choice, provides a few ways to monitor your subscriptions and notify you when new entries are available. None of these support Growl, as far as I’m aware, but it turns out that it’s trivially easy to create one.
Here’s a simple shell script that checks an account at Bloglines every 60 seconds and sends a notification to Growl when there are new items:
URI="http://firstname.lastname@example.org&ver=1" COUNT=0 while [ 1 ] do NEW=$(curl -s "$URI" | cut -f2 -d'|') if [[ $NEW > $COUNT ]] then echo $NEW unread entries | growlnotify "Bloglines" fi COUNT=$NEW sleep 60 done
To use this, replace “
email@example.com” with your Bloglines account name (i.e., your e-mail address). The variable
URI is part of Bloglines’s notifier API, which provides an easy way to check the number of unread items for an account.
curl to dereference the URI and
cut to select the field containing the number of unread messages. If the number of unread messages has increased, we use
growlnotify to send a notification to Growl. Finally, we use
sleep to wait a minute before checking again.
Obviously, this is extremely primitive. If you’ve never used the OS X command line, then this is not the tool for you.