Page 1 of 1

Matching when a volume is NOT mounted

PostPosted: Tue Feb 01, 2022 2:16 am
by JohnDCCIU
I want Hazel to notify me when a volume is not mounted, when it previously was mounted. The machine I'm running Hazel on is always supposed to have a volume mounted, but when ever it isn't, we want to know.

I'm running Hazel 5.1.1 on macOS 10.15.7. Hazel is properly set to have Full Disk Access.

So I set Hazel to look at the folder "/Volumes" and I set the condition to Passes Shell Script, Embedded Script, with this code in the Script:
Code: Select all
test -d "/Volumes/<volume name>"
if [[ $? -eq 1 ]]
then
   exit 0
else
   exit 1
fi


When I dismount the volume, the Hazel log shows that it recognizes the change and processes the /Volumes folder....but it doesn't show that it matches and doesn't trigger the action to notify me.

I ran the same code in a test shell script manually in Terminal and it properly returns exit code "0" when the volume is not mounted. My understanding is that exit code 0 tells Hazel to match the condition and run the actions, but it's not doing that for some reason.

Any hints as to what I might be doing wrong? Thanks!

Re: Matching when a volume is NOT mounted

PostPosted: Tue Feb 01, 2022 10:25 am
by Mr_Noodle
Hazel cannot run a rule on something that does not exist. Assuming I understand you correctly and that you have Hazel monitoring /Volumes, your rule would be evaluated against every volume on your system, while testing for that one volume. Note sure if this is the intended effect.