Connecting AirPods (or Pro) to Mac via keyboard
I'm in telcos much of the day, and with an iPhone next to me, it's not always crystal clear that the AirPods Pro are indeed connected to the Mac before I join Teams. I wanted a mouse-free way to make sure of that.
If that's also you, here's a BetterTouchTool script to make it happen. We need the terminal, Homebrew and BetterTouchTool.
This BTT script will connect the AirPods (Pro), then it'll switch the audio output to them, and then you'll hear the computer say "Boom". It should work the same with all Bluetooth headphones.
If you're missing Homebrew, BluetoothConnector or SwitchAudioSource, first install Homebrew, and:
brew install BlueToothConnector
brew install switchaudio-osx
Here's the actual script template for M1 Mac. You do need to modify it. For Intel, Brew will install the command to /usr/local/bin instead. Use "which BluetoothConnector" to find it.
/opt/homebrew/bin/BluetoothConnector -c aa-bb-cc-dd-ee-ff && /opt/homebrew/bin/SwitchAudioSource -s "👻 Airpods Pro" && say "Boom"
That's all one line. The "&&" must be followed immediately by the second line. Whitespace, not Enter. It's three commands in a chain. If the first succeeds, the next is performed and so on (&&).
You must change "aa-bb-cc-dd-ee-ff" and "👻 Airpods Pro" with the Bluetooth address of your AirPods, and the name of your AirPods.
You can copy-paste both of them from the results of this command:
BluetoothConnector
Then, you bind that modified one-liner into a keystroke in BetterTouchTool. See images. And that's it.
This may be documented elsewhere, and if so, here's one more Google hit, hope this helps. Let me know if it did or didn't. If you've never used Terminal, read Homebrew docs and make sure you've got Xcode and Command Line Tools installed. Without those it won't work.