Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

New mail notification using the PowerMate Apps
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...]
    •    
  • Currently 3.75 / 5
  You rated: 4 / 5 (4 votes cast)
 
[11,792 views]  

New mail notification using the PowerMate | 14 comments | Create New Account
Click here to return to the 'New mail notification using the PowerMate' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
New mail notification using the PowerMate
Authored by: macevangelist on Mar 16, '04 11:52:02AM

try
	tell application "System Events" to if (exists process "Mail") is false then
		set theCount to 0
	else
		tell application "Mail" to set theCount to unread count of inbox
	end if
	
	if theCount > 0 then
		tell application "PowerMateDriver" to set pulse always to true
	else
		tell application "PowerMateDriver"
			set pulse always to false
			set brightness to 0
		end tell
	end if
end try


[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: SCID on Mar 16, '04 12:00:55PM
I do the same thing but use Mail.app's filters to pulse the PowerMate. I have filter that fires when ever an email is recieved from some one in my Address Book Group "Clients" and it fires the following appleScript
tell application "PowerMateDriver"
	get pulse always
	set pulse always to true
	get pulse rate
	set pulse rate to pulse rate + 1
end tell
So the faster the PowerMate is pulsing the more mail I have from clients. The I have another script in mail's script menu that resets the powermate to a low pulse rate and turns off pulsing. By the way I have a variant on this script that gets fired when I get mail from my wife that makes it flicker like a nut-case (the powermate not the wife) ;) Sam D ps apple script can check for a process running
tell application "System Events"
	if exists process "Mail" then
		display dialog "Mail Running"
	end if
end tell


[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: superuser on Mar 16, '04 03:32:46PM

@ SCID:
>> Then I have another script in mail's script menu that resets the powermate to a low pulse rate and turns off pulsing.<<

I would like to make the PowerMate puls - 1 (one less) by selecting (and thus flag it 'read') an unread mail.
In other words, when I browse trough my inbox and have selected/read every message, the PowerMate stop pulsing.
Is this possible?

cheers



[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: rputter on Mar 16, '04 03:56:39PM

This sounds really fantastic. Can anyone tell me how to do this in a for dummies approach. Right from when I launch terminal? Also, can it be done for Entourage?

Many thanks for any help anyone can give,

Rohan



[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: olivesoft on Mar 16, '04 06:57:21PM
To make it so you don't need a crontask, make the AppleScript and Stay Open Application by choosing "Application" from the File Format popup in the Save As dialog and the "Stay Open" option. The "return 60" at the end of the idle handler will cause it to be executed every 60 seconds. This way, you can just add it to your Login Items (or Startup Items in Panther) instead of having to rerun it every minute. on idle try tell application "System Events" to if (exists process "Mail") is false then set theCount to 0 else tell application "Mail" to set theCount to unread count of in mailbox end if if theCount > 0 then tell application "PowerMateDriver" to set pulse always to true else tell application "PowerMateDriver" set pulse always to false set brightness to 0 end tell end if end try return 60 end idle

---
-Bob
---------------------
I tend to think of [Mac] OS X as Linux with QA and Taste.
-James Gosling, Java Architect

[ Reply to This | # ]

New mail notification using the PowerMate
Authored by: olivesoft on Mar 16, '04 07:00:54PM
Sorry for the formatting...

on idle
	try
		tell application "System Events" to if (exists process "Mail") is false then
			set theCount to 0
		else
			tell application "Mail" to set theCount to unread count of in mailbox
		end if
		if theCount > 0 then
			tell application "PowerMateDriver" to set pulse always to true
		else
			tell application "PowerMateDriver"
			        set pulse always to false
			        set brightness to 0
	     end tell
        end if
    end try
    return 60
end idle

---
-Bob
---------------------
I tend to think of [Mac] OS X as Linux with QA and Taste.
-James Gosling, Java Architect

[ Reply to This | # ]

New mail notification using the PowerMate
Authored by: asan102 on Mar 16, '04 08:48:01PM

The easier and better way to do this is simply make an applescript that sets the powermate pulsing (or pulsing +1 if you want) and set it to launch every time you receive a new message (choose Any from the pop-up when setting up a new event). It's easier because it doesn't require the terminal, and better because it uses less system resources by taking advantage of mail's built-in way of doing thing, rather than launching a script every 5 minutes or so.



[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: dggraphics on Mar 17, '04 11:03:35AM

The easiest way is just to take the new script which was added in the latest PowerMate driver update, LED Tickler. This applescript causes the PowerMate to momentarily strobe. This script can then be added as a regular mail rule. I have mine set to pulse when I receive new mail. I have also used this script in conjunction with iCal alarms.



[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: Werd on Mar 22, '04 01:08:37AM

I remember a little program from years ago that would make the caps/num/scroll lock lights on the keyboard flash - even reacting to music like a mini VU meter (this was back when the three lights were still all in a row at the top of the keyboard). For those of us without PowerMates, a little script to control the on/off state of the caps lock and num lock lights could be very handy. I would love to have my num lock light flash when I have mail waiting, since I can't tell without waking the screensaver or bringing the display out of sleep. Does anyone know how to temporarily override the lights for these keys?



[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: therobloe on Mar 23, '04 12:53:31AM

http://www.osaxen.com/jons_commands.html

These commands enable "keyboard lights", which can be used, by a decent applescripter, which I am definitely not, to do those very cool things you're describing



[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: Werd on Apr 01, '04 12:01:31AM

From the developer:
"Keyboard lights no longer works. It was ADB based, and does not work for USB keyboards. It is not even present in Jon's Commands X."

That's too bad, since it would have been a great solution. Does anyone have any other ideas?



[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: Nabeel_co on Apr 05, '06 05:52:33PM

That would be ssooo cool! Was that program for Mac OS >9 or OS X or Windows.
I am sooooo looking for that program!



[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: craigp on May 19, '08 06:02:16AM
I did some work on this, as none of the solutions really did what I wanted. I wanted Mail.app to fire off a script when new mail came in, set the throb, then keep checking until I read the new mail. This script will do that, and then get itself in to a checking loop until you read the email, at which point the script will exit. In other words, you won't need to have a script running all the time.

-- say "Checking email"
set shouldContinue to 1
repeat while shouldContinue is 1
	try
		tell application "System Events" to if (exists process "Mail") is false then
			set theCount to 0
		else
			tell application "Mail" to set theCount to unread count of inbox
		end if
		if theCount > 0 then
			tell application "PowerMateDaemon" to set pulse always to true
			--say "Unread email found"
		else
			tell application "PowerMateDaemon"
				set pulse always to false
				set brightness to 0
				set shouldContinue to 0
				--say "No more unread email"
			end tell
		end if
	end try
	delay 2
end repeat
--say "Finished"


[ Reply to This | # ]
New mail notification using the PowerMate
Authored by: craigp on May 19, '08 06:04:00AM

Oooh. Forgot to say: you will want to use Script Editor to create this script, save it somewhere, then create a new rule in Mail.app for 'Every message' that fires this scripts. Job done.



[ Reply to This | # ]