Hardwaregrowler 2 2

broken image

(from our scripting dictionary, only title, description, icon, sticky, and priority are modifiable)
Growl invokes the rules script using by getting an NSUserScriptTask for the Rules.scpt file (and only if it comes back as an NSUserApplescriptTask). It's executed using our event descriptors, but the actual execution is done outside our process and sandbox. Compiled AppleScript scripts should work with the right extension, but I have never tried working with other OSA languages such as javascript. I will look at seeing if I can get a hello world sample JXA script working, but not holding my breath.
The original intent was to allow true unix scripting for rules with json inputs/returns, but there were problems with the NSUserUnixTask (I think I was having problems getting return values).
NoteType is visible to the user under an application's entry in 'Applications' in preferences. On the notifications tab for the application, on each note at the bottom of its preferences is a label labeled 'Rule Type:' Note that some apps use long-ish names here, just drag select to select it all before copying.
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.
unread,Apr 12, 2017, 7:42:42 PM4/12/17
The apparent quirkiness and debugging difficulty, on top of the pseudo-natural language style, makes AppleScript rather challenging for me. :-)
using terms from application 'Growl'
on evaluate notification with notification
set backupVolume to 'LaCie'
set mountedMessage to backupVolume & ' Mounted'
set unmountedMessage to backupVolume & ' Unmounted'
if notification's app name equals 'HardwareGrowler' then
if notification's note title equals 'On Battery Power' then
set TimeMachineIsRunning to do shell script 'tmutil status'
if TimeMachineIsRunning contains 'Running = 0;' then
tell application 'Finder'
if disk backupVolume exists then eject disk backupVolume
end tell
-- The bit below seems to make the script hang. Still-present
-- volume icon will have to be enough feedback.
(*

else
set alertMessage to ¬
'rWarning: Time Machine backup in progress, ' & ¬
'cannot auto-eject backup volume ' & backupVolume & '.'
set notification's note description to ¬
notification's note description & alertMessage

end if
else if notification's note title equals mountedMessage then
do shell script 'sudo tmutil enable;sudo tmutil disablelocal'
else if notification's note title equals unmountedMessage then
do shell script 'sudo tmutil disable;sudo tmutil disablelocal'
end if
end if
to Growl Discuss
Not sure what's up with the hang =/
Unfortunately it appears that the JAX script is silently failing when used for rules
My apologies that I couldn't be more help
Daniel
Reply all
Forward




broken image