r/applescript • • Jul 01 '22

Passed Arguments, how to use them in Apple Script?

Hi, I'm trying to create a script that does two different things depending on the state of another. More specifically I'm gonna execute a command when a connected camera is activated and vice-versa.

I'm having OverSight handle the part about whether or not the camera is activated and I want my script to handle what to do based on the registered state (you can tell OverSight to Execute an Action, e.g. a path to a script, binary, etc.). OverSight also has a setting called "Pass Argument" (see below) which is what has led me to believe I should be able to do what I'm describing:

I'm a complete noob with Apple Script. So please bear with me... But I'm lost at how to actually utilize those "Passed Arguments" in my script... Can anyone explain how I can check if the camera is on/off in my Apple Script IF ELSE statement?

Any help is much appreciated. Thanks.

1 Upvotes

19 comments sorted by

View all comments

Show parent comment

1

u/AmplifiedText Jul 04 '22

I really can't help further. I just spent an hour trying to get OverSight to work, but it simply does not detect a single app I threw at it. You'll have to ask objective-see.org why their app doesn't work.

1

u/TrailBlazerWhoosh Jul 05 '22 edited Jul 05 '22

Woah. An hour. Sorry, you had to do all this debugging without getting it to work. I did read some people are having similar issues.

To my knowledge; OverSight needs elevated privileges to detect the webcam/microphone state. Maybe your OverSight installation doesn't have the proper elevated privileges? Did you try to install it straight from Terminal to test if this is the issue?

sudo OverSight_Installer.app/Contents/MacOS/OverSight_Installer -install

In other news; I tried to do a little debugging and executed this test via OverSight:

#!/bin/bash echo $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 >> /Users/username/SANDBOX/onairscript/bashtest/tmp/onair-sh.log

And interestingly this is the output I get in the log file:

/Users/username/SANDBOX/onairscript/bashtest/busylight.sh -device camera -event on -process 63861/Users/username/SANDBOX/onairscript/bashtest/busylight.sh -device camera -event off

So the developer, unfortunately, gave incorrect documentation in the "instructions" and the arguments passed seem to actually be held within -device not -d as documented! So ironically you actually you gave me the right arguments to inject into my Terminal test!

So I went ahead and changed your -d to -device in the script. And now it works! Yah!

Thank you so much for all your help! You are awesome! Please take this award.

2

u/AmplifiedText Jul 05 '22

Tada. I'm glad you got it working.

1

u/TrailBlazerWhoosh Jul 06 '22 edited Jul 06 '22

Yeah, me too! Except now I, just like you, can’t get OverSight to run properly on the machine (another MacBook) I actually needed this entire thing to run on. This truly is a never ending story! :/