How does Growl invoke the ~/Library/Application 
Scripts/com.Growl.GrowlHelperApp/Rules.scpt file?  Notwithstanding the ".scpt" 
suffix, it works fine if Rules.scpt has plain text AppleScript in it; but if it 
could have a "compiled" script in there instead, anything listed by osalang 
could be used; for Yosemite and later, that includes JavaScript.

And that doesn't even count having the script use "do shell script" not only to 
take some unusual action, but by passing the interesting properties of the 
notification, give the script some ability to choose what to do about it.   
Quoting the properties safely yet keeping them separate while passing them 
might be a tricky proposition, and not one I wish to explore right now. :-)

What are examples of what the "note type" property might have in it, anyway?  I 
don't see that field shown in the history, and didn't need it in this case, so 
I didn't fool with a temporary script just to see what all the properties 
looked like.

One more question: if I want to modify a property (the note description, in 
what I have in mind, by appending some text to it), do I have to explicitly 
return the notification, or will the default behavior see the change?  I saw an 
example of doing things when switching to battery power, and I think I can hook 
in some code that, when AC is removed, checks if a backup is running, and if 
not, ejects the backup volume (if it's mounted).  If a backup _is_ running, I 
may want to append "\r Note: cannot auto-eject backup volume" to the 
notification text for going on battery; otherwise, I ought to generate an 
additional visual indication ("display alert", or can I send an additional 
notification within the rules script, without messing up the notification I'm 
responding to? and wouldn't I have to make up a bogus application name for 
that?").

> On Apr 10, 2017, at 11:59, Chris Forsythe <[email protected]> wrote:
> 
> I believe if you want something more esoteric you can execute a script in a 
> different language. I'm not sure on how to accomplish it but I'm sure the 
> googles do. I'm glad this is headed in the direction you need though, it's 
> definitely something we added with this sort of usage in mind.
> 
> On Fri, Apr 7, 2017 at 6:40 PM, Richard L. Hamilton <[email protected] 
> <mailto:[email protected]>> wrote:
> Well, this seems to do what I want, as near as possible - enable or disable 
> Time Machine depending on whether the backup drive is mounted, and in either 
> case (since this doesn't seem to be remembered!) turn off local snapshots, 
> which seem to me not a great idea with an SSD, at least if one doesn't need 
> such a guarantee that backups will be particularly recent.
> 
> using terms from application "Growl"
>    on evaluate notification with notification
>       if notification's app name equals "HardwareGrowler" then
>          if notification's note title equals "LaCie Mounted" then
>             do shell script "sudo tmutil enable;sudo tmutil disablelocal"
>          else if notification's note title equals "LaCie Unmounted" then
>             do shell script "sudo tmutil disable;sudo tmutil disablelocal"
>          end if
>       end if
>       -- absent an explicit return, defaults are used
>    end evaluate notification
> end using terms from
> 
> This does assume that the account using it is able to do a "sudo" without 
> password; other than that and the name of the volume mounted or unmounted, 
> it's probably fairly generic for such a use.  Having the Script Editor show 
> me Growl's dictionary, along with looking at actual recent examples in the 
> Growl log, provided the information I needed.
> 
> AppleScript was clearly descended from something intended to appeal to 
> non-programmers; as such, it makes my head hurt a bit; but for something 
> small that can't as easily be done any other way, I guess I can live with 
> that. :-)
> 
>> On Mar 27, 2017, at 14:13, Chris Forsythe <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> It's fine I think you're golden with Growl given it has two events. I'd 
>> really suggest the applescript rules. Think of applescript as just a 
>> different language and don't try to make it a 1:1 comparison to say bash or 
>> python. It's more like plain talking so to speak.
>> 
>> Anyhow you could write a script to watch for the contents for the different 
>> things you want to watch for. The very end of our documentation talks about 
>> how to execute a shell script from there:
>> 
>> http://growl.info/documentation/applescript-rules 
>> <http://growl.info/documentation/applescript-rules>
>> 
>> I think this is going to handle what you need and be fairly simple once 
>> you've got it worked out in your head and laid out. If you read it and run 
>> into issues once making the script reply back here.
>> 
>> 
>> On Sat, Mar 25, 2017 at 2:27 AM, Richard L. Hamilton <[email protected] 
>> <mailto:[email protected]>> wrote:
>> (apologies if this is a dupe; it looked like it failed before, when I had a 
>> cc to [email protected] 
>> <mailto:[email protected]> when my membership hasn't 
>> been approved yet)
>> 
>> I'd like to have a script run
>> sudo tmutil enable
>> when /Volumes/LaCie is mounted, and
>> sudo tmutil disable
>> sudo tmutil disablelocal
>> 
>> when it's unmounted (I don't want local snapshots on the internal SSD, but 
>> tmutil disablelocal doesn't seem to be remembered across reboots; it's good 
>> enough that I have backups running when the Thunderbolt drive is plugged in).
>> 
>> Additionally, for that and any other mount/unmount not in HardwareGrowler's 
>> exception list, I'd like the usual visual notification.
>> 
>> Assume that I've tweaked /etc/sudoers or otherwise made arrangements (such 
>> as porting Linux pam_ssh_agent_auth.so and configuring it) so that I don't 
>> need to enter my password for sudo.  And of course, the system won't let me 
>> unmount the drive if it's in use (not counting forced unmounts), so the 
>> script doesn't need to worry about that.
>> 
>> I've never really worked with AppleScript, and have no idea how the 
>> arguments (like whether it's a mount or unmount, and what the mount point 
>> is) are passed, so some help would be great!
>> 
>> I'd actually rather use ControlPlane than HardwareGrowler+Growl, but 
>> ControlPlane doesn't (AFAIK) have a mount/unmount "evidence" source, and 
>> neither HardwareGrowler nor ControlPlane seem to have a provision for 
>> noticing the connection/disconnection of Thunderbolt devices.
>> 
>> thanks...
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Growl Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <mailto:[email protected]>.
>> To post to this group, send email to [email protected] 
>> <mailto:[email protected]>.
>> Visit this group at https://groups.google.com/group/growldiscuss 
>> <https://groups.google.com/group/growldiscuss>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
>> 
>> 
>> 
>> -- 
>> Chris Forsythe
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Growl Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <mailto:[email protected]>.
>> To post to this group, send email to [email protected] 
>> <mailto:[email protected]>.
>> Visit this group at https://groups.google.com/group/growldiscuss 
>> <https://groups.google.com/group/growldiscuss>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Growl Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/growldiscuss 
> <https://groups.google.com/group/growldiscuss>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> 
> -- 
> Chris Forsythe
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Growl Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/growldiscuss 
> <https://groups.google.com/group/growldiscuss>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Growl Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/growldiscuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to