Quit / open an app whenever audio output is changed on mac

Solution 1:

Well, many thanks to CJK for the explanations!

After some struggle with Keyboard Maestro (because of how Boom is made, a Boom2device appears in the sound output devices and never really changes, so the trigger from Keyboard Maestro doesn't work...) I tried user3439894's solution and got Eventscripts to work in less than 10 minutes!

The real plus with EventScripts is that you can choose which Bluetooth devices trigger the AppleScript.

Here's my set up:

enter image description here

With some scripts easy as:

  • Quit Boom:

    quit application "Boom 2" 
    

or

  • Activate Boom:

    tell application "Finder"
        activate
        open application file "Boom 2.app" of folder "Applications" of startup disk
    end tell
    

I also made another one that came in my mind to adjust the brightness of the screen after plugging the MBP to the power with brightness.