* * * * * /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...]

