monitor growl messages

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

monitor growl messages Wed May 23, 2012 2:06 pm • by La_Tristesse
Is there anyway to monitor respectively react on certain growl notifications like "Volume XY is mounted"?

Regards
La_Tristesse
 
Posts: 18
Joined: Sun Mar 21, 2010 4:42 pm

Re: monitor growl messages Wed May 23, 2012 2:43 pm • by Mr_Noodle
That type of thing is not really within Hazel's purview. You might want to look around for another tool to do this type of thing.
Mr_Noodle
Site Admin
 
Posts: 11270
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: monitor growl messages Thu May 24, 2012 7:58 pm • by a_freyer
Growl does post messages to the system log. Although Hazel is not meant to do this, it would be trivial to tail the system log periodically and awk or grep the message that you're looking for.

But, like mr_noodle says - that's not what Hazel is really for.

If you're looking for an alert when a specific volume mounts in order to perform actions on the volume, search the forum for "action on mount" or something similar. There are plenty of examples of how to perform within a volume that recently mounted.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: monitor growl messages Thu May 31, 2012 1:28 pm • by La_Tristesse
Thanks the answers.

@ a_freyer

Could you explain further and give a example?
La_Tristesse
 
Posts: 18
Joined: Sun Mar 21, 2010 4:42 pm

Re: monitor growl messages Fri Jun 01, 2012 9:00 pm • by a_freyer
La_Tristesse wrote:Thanks the answers.

@ a_freyer

Could you explain further and give a example?



Here is a quick and dirty example that will give you the text of the last Growl alert seen by the system:

Code: Select all
tail -50 /private/var/log/system.log | grep "Growl\[" | grep -Ev "\-\-\-|Reserving" | tail -1| sed -n -e '/^[^(]*(\([^)]*\)).*/s//\1/p'


But, like mr_noodle said - are you sure this is what you want to do? What is your objective?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: monitor growl messages Sat Jun 02, 2012 3:28 am • by La_Tristesse
Thanks again. So I will to have to create a hazel rule which runs on systemlog or do I have to use a LaunchAgent?
I want to mount my iphone via sshfs and iproxy everytime connect over usb. I also tried to achive that with controlplane but this doesnt work for me.
La_Tristesse
 
Posts: 18
Joined: Sun Mar 21, 2010 4:42 pm

Re: monitor growl messages Sat Jun 02, 2012 11:57 am • by a_freyer
Hazel isn't the tool for you then. You'd only be using Hazel to run a periodic script - a sledge hammer to kill a mosquito.

I'd do this to detect for the iPhone mounting over USB:

Code: Select all
system_profiler -xml SPUSBDataType | grep -c "iPhone"


This will return 1 or 0 whether the phone is plugged in USB or not.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: monitor growl messages Sat Jun 02, 2012 4:12 pm • by La_Tristesse
Thanks, but how do I monitor this? I don't get it. Do I have to run a bash script with the launchagent every 30 seconds or how do I achieve that.
La_Tristesse
 
Posts: 18
Joined: Sun Mar 21, 2010 4:42 pm

Re: monitor growl messages Mon Jun 04, 2012 12:21 am • by a_freyer
La_Tristesse wrote:Thanks, but how do I monitor this? I don't get it. Do I have to run a bash script with the launchagent every 30 seconds or how do I achieve that.



Sure, but this isn't particularly efficient, and as said before: this is not what Hazel/support forum is for. I'd suggest redirecting this question to StackOverflow.

This bash script will work fine as an example:

Code: Select all
#!/bin/bash

if [ $(system_profiler -xml SPUSBDataType | grep -c "iPhone") == 1 ] 
then
   open "/PathToiProxy"
fi
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado


Return to Support