I was frustrated to find I couldn't set the PowerMate to pulse when I got new mail. There was once a program called MailPulse that did this, but the developer's site has taken it down, and it may or may not ever return. I found a way to do this using the sample AppleScripts included in the PowerMate driver, and wanted to share. I put the script in my crontab using osascript:
* * * * * /usr/bin/osascript /Users/Foo/powermail.scpt
Disclaimer: I am terrible at Applescript so if you've got a better way to do this, please let me know!
Here's the script. I set it to exit if Mail isn't running, so it doesn't auto-start Mail. I couldn't figure out how to do that in AppleScript, so I cheated and used a Shell escape. Suggestions for improvements are welcome:
set my_mail_running to {do shell script "ps -ax | grep -c Mail.app"}
if my_mail_running is greater than or equal to 3 then
using terms from application "Mail"
tell application "Mail"
set theCount to unread count of inbox
(* display dialog theCount *)
end tell
end using terms from
if theCount > 0 then
tell application "PowerMateDriver"
get pulse always
set pulse always to true
end tell
else
tell application "PowerMateDriver"
get pulse always
set pulse always to false
get brightness
set brightness to 0
end tell
end if
end if
[robg adds: No PowerMate here, so I can't test this one...]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040310012124833