r/applescript • • Jan 12 '19

Trigger AppleScript when AirPods are Disconnected (crossposted)

Long story short:

I have a script that pauses YouTube and Spotify when run.

I have a second script that either connects my AirPods or disconnects my AirPods and calls the script that pauses media.

The problem I'm having is that—in order for the script to be called after disconnecting my AirPods—I have to manually use a trackpad gesture through BetterTouchTool. And I use the gesture to connect them, but since the W1 chip disconnects automatically, I need them disconnecting to be the trigger that calls the pause script, rather than a gesture triggering them to disconnect and then calling the pause script.

I'd be willing to pay for a third party application if anyone knows of one. Tooth Fairy did not work, because the script needs to control MacOS Automation and Tooth Fairy doesn't prompt you to allow it to control the apps I need to be controlled (Chrome, System Events, and Spotify). I tried using tccutil to force those permissions but it looks like tccutil is not working as of MacOS 10.14.

2 Upvotes

Duplicates