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