[Feature] - Option to run script on status change
Opened this issue · 7 comments
it would be super cool if there was an option to call a script on status change (Cam On/Off, Mic on/off). This could be handy for folks who might want to have an "On Air" light outside their home office to let family know when they're on a call. Since Oversight knows what is a cam and a mic, probably the simplest thing to do would be to is just to pass the following as arguments to the script.
- CameraOn
- CameraOff
- MicOn
- MicOff
Then the user can have their script handle the above arguments as needed to make whatever IoT or USB thing they use for an On Air light.
I see that this is implemented in 2.0. I wish a small help is written to showcase how this works
Also, I think this is not working.
I used sh ~/Code/run_cam_status.sh
as the script and it doesn't seem to get triggered
v2.0
Big Sur 11.4
Patrick: Happy to see that this was implemented so quickly so I can make an On Air light. :¬)
I whipped up a quick test script and called it onair.sh
#!/bin/bash
echo $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 >> /tmp/onair-sh.log
This appears to be a minor UX issue. The first time I put in the script for it to call, it wasn't calling it. Checking Console.app, I see the following logs.
default 11:07:27.125610-0700 OverSight [com.objective-see.oversight] Adding notification request 5E4A-DB74
error 11:07:27.125807-0700 OverSight ERROR: (null) is not a valid action
The error indicates that it doesn't have a path for the script. Odd. The script was in a sub directory of my homedir. Wondering if Oversight needed permissions to access my homedir, I moved the script to /tmp/ and updated OverSight preferences, hitting enter in the path box when done. The hitting enter is what seemed to tell OverSight to save the preference. Once that was working, I pointed OverSight back to the path in my homedir and it continues to work.
Maybe an explicit save
button on the prefs is in order?
I'm confirming this feature is now working on the 2.0.0 release. Like the previous comment, I had to press the "return" key to get the script setting to save, but after that it gets triggered during events. Thanks for adding the feature!
@ducksauz and @jessehs i can't get it to work. Maybe one of you will spot my error immediately.
I have the following file in the folder /Users/xxx/busylight/busylight.sh
Content of this file is
#!/bin/bash echo $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 >> /Users/xxx/busylight/tmp/busylight.log
also created the "tmp" subfolder and added the emtpy file busylight.log
In oversight my settings look like this:
I saved the path with return and also tried it without sh. Any guesses what I am doing wrong?
Thanks for your help!
@nasenfloete when it was working for me, I had this entered in the Execute Action text-field:
/Users/redacted/scripts/onair.sh
In other words, it did not have the sh
in front of it. When you make the change, hit the "return" key to save it.
Other ideas:
- ensure the file is marked as executable "chmod +x /Users/xxx/busylight/busylight.sh"
- Ensure that you're getting the notifications on screen when the camera/mic turn on and off. (Since I upgraded to Mac OS 12 Monterey, everything stopped working for me, including these notifications. I'm following another issue thread where that was reported.) I would assume that if the notifications work for you, then the script should work too.
- Try adjusting permissions on the directory and file the script is writing to. For debugging, try "chmod -R 777 /Users/xxx/busylight/tmp" just to see.
@jessehs Thanks so much for your quick help! The chmod tip was the solution! Now it works - I also don't get any notifications since I added the script, but at least for microphone it works pretty well now 😄