Switch to app after clicking on a msg sent from growlnotify

The Growl forums have moved to Google Groups, this forum is read only.
dizzydragon
Harmless
Posts: 2
Joined: Sun Aug 23, 2009 10:25 pm

Switch to app after clicking on a msg sent from growlnotify

Postby dizzydragon » Sun Aug 23, 2009 10:45 pm

Hi everyone,

I recently discovered growlnotify and enjoyed messing around with it a bit (I'm no expert, so just messing, really)
For example, I use it via a simple AppleScript to remind me of certain iCal-Events:

Code: Select all

do shell script "echo check iCal! | /usr/local/bin/growlnotify -s -a iCal Urgent Event"


Now I wonder if there's a way to make it so that after clicking on this notification, iCal becomes the actice application?
I notice that in the Growl Preference Pane there is a checkbox labelled "Inform growlnotify when a notification is clicked".
What does that do, exactly? Is there a way to specify the way growlnotify reacts on this information?

Thanks in advance for your help and useful information =)
dizzy

User avatar
boredzo
Cocoaforge Admin
Posts: 796
Joined: Mon Dec 06, 2004 7:49 am
Contact:

Re: Switch to app after clicking on a msg sent from growlnotify

Postby boredzo » Mon Aug 24, 2009 12:01 am

dizzydragon wrote:I notice that in the Growl Preference Pane there is a checkbox labelled "Inform growlnotify when a notification is clicked".


Every application gets that checkbox. It's not specific to growlnotify; there are no special cases to either force it to be present or to omit it.

What does that do, exactly?


It allows the application to receive click feedback. The checkbox exists so you can tell Growl to not tell the application when you click on notifications (that is, disable click feedback), in case you want to be able to just click anywhere in the notification to close it without the application reacting in any way.

Is there a way to specify the way growlnotify reacts on this information?


No, because growlnotify doesn't react to it at all. By default, it doesn't even wait for it: If you run growlnotify from the Terminal, you'll see that it exits immediately.

You can tell growlnotify to wait for the notification to be dismissed, and then you can wait for growlnotify, but you still won't know whether it was a click or an automatic fade-out (which may not even make sense, since the notification may have gone to a non-visual display).

dizzydragon
Harmless
Posts: 2
Joined: Sun Aug 23, 2009 10:25 pm

Re: Switch to app after clicking on a msg sent from growlnotify

Postby dizzydragon » Mon Aug 24, 2009 10:02 am

Thanks for these insights!

The -w option is sufficient for my needs as far as I can tell, since I use a sticky notification, which is only dismissed when clicked on afaik. Btw, -w on growlnotify doesn't seem to have to do much with the option "Inform [application] when a notification is clicked", because no matter if that option is checked or not, growlnotify exits when the notification is clicked.

Anyway, after nearly going insane over the last three lines of script, I managed to get it working the way I want:

Code: Select all

do shell script "echo check iCal! | /usr/local/bin/growlnotify -s -w -a iCal Urgent Event"
tell application "iCal"
   activate
end tell
tell application "System Events"
   keystroke "t" using command down
end tell


Thanks again for your help, I guess I've had enough of AppleScript for a while...
(Fun fact: after one hour of googling, I was not able to find an AppleScript command to tell iCal directly to display the current date without emulating the keyboard input)

User avatar
boredzo
Cocoaforge Admin
Posts: 796
Joined: Mon Dec 06, 2004 7:49 am
Contact:

Re: Switch to app after clicking on a msg sent from growlnotify

Postby boredzo » Mon Aug 24, 2009 10:05 am

dizzydragon wrote:The -w option is sufficient for my needs as far as I can tell, since I use a sticky notification, which is only dismissed when clicked on afaik.


Correct as long as the notification goes to a visual display. Non-visual displays have no concept of sticky, or of being clicked on.

Btw, -w on growlnotify doesn't seem to have to do much with the option "Inform [application] when a notification is clicked", because no matter if that option is checked or not, growlnotify exits when the notification is clicked.


That's because growlnotify is waiting for the notification to disappear from the screen. It doesn't care whether that happens by a click or by a time-out, and if you uncheck that box, it always looks like a time-out to growlnotify.


Return to “Growl”

Who is online

Users browsing this forum: No registered users