I'm using Boom as an equalizer and a File Audio Boosting on my MBP when using built-in speakers. But when using a home device (with an amplifier connected by jack to the MBP) or a headphone (bluetooth or jack) I prefer to disconnect Boom.

So far I have made an automator script that connect/disconnect bluetooth and quit/launch Boom.

Is there a way to upgrade my current script to be triggered with plugging/unplugging of jack or connecting/disconnecting with bluetooth device (not only when activating/disactivating bluetooth)?

Note : I'm aware of Breakaway that Automatically disable speakers when headphones are removed (but only by manually connect/disconnect the jack), but something that quit/launch a specific app will suit me better.

For the curious, here my current script using Blueutil :

set BT to do shell script "/usr/local/bin/blueutil -p"

if BT is equal to "0" then
    do shell script "/usr/local/bin/blueutil -p 1"
    tell application "Boom 2" to quit
    do shell script "/usr/local/bin/blueutil -p 0"
    tell application "Boom 2" to activate
end if
  • 1
    You would probably need a third-party app like Keyboard Maestro that can trigger scripts (amongst other things) in response to different events occurring on your system. It's a paid app, but the trial period will let you determine whether it suits your needs. AppleScript can do the bits you're already having it do, but it can't listen for Bluetooth events. – CJK Nov 7 '19 at 12:52
  • Thanks for the tip ! I will try it when I can.. But are you insinuating that applescript cannot automatically run something with a trigger (like unplugging headphone) ? – Edd Growl Nov 7 '19 at 14:54
  • 2
    Have a look at EventScripts It's $3.99 at the US App Store, but a free demo is downloadable from the developers website. Note: I am not affiliated with the developer of EventScripts, just a satisfied user of the product. – user3439894 Nov 7 '19 at 15:35
  • 1
    A little more than insinuating, but yes. With the exception of Folder Actions, AppleScript can't/doesn't monitor low-level system events, so cannot be used to create triggers. Some scriptable apps provide triggers for higher-level in-app events that AppleScript can use, eg. BBEdit application/document listeners. But for a sustainable, usable solution, you want the means to listen for messages the system broadcasts whenever something happens. What you don't want is an AppleScript repeat loop badgering the system with "are we there yet?". – CJK Nov 7 '19 at 15:53
  • Actually, any form of polling is not good, but it's the only thing AppleScript can do. The exception to this is by way of AppleScriptObjC, which one could borrow the means to create "observers", each tailored to listen for specific events. The observer would hear the messages reporting, say, Bluetooth state changes, and call a user-defined handler. It would be an AppleScript application that stays idle in the background. It's probably not a bad solution, but there are more ideal languages in which to implement this solution, say, as a background process or command line tool. – CJK Nov 7 '19 at 16:15

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" 


  • Activate Boom:

    tell application "Finder"
        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.

| improve this answer | |
  • This is awesome. I must definitely revisit EventScripts. If I recall, there's an accompanying iOS app too. +1 – CJK Nov 7 '19 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .