Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

petterihiisila

macrumors 6502
Original poster
Nov 7, 2010
404
304
Finland
I'm one of those who like to have a keyboard shortcut for everything. AirPods auto-switching works better with iOS and iPadOS than it does with my M1 Macbook Air. Also, I dislike having to click Connect every time with the trackpad. I want a keyboard shortcut key that I can press just in case, before joining a Teams call and be sure that the headphones are connected.

I previously had a solution with BetterTouchTool and BluetoothConnector (Homebrew), but it's not reliable with AirPods, because they are kind of always connected. The key was to add a command to actually set the AirPods Max as the sound output. Luckily Homebrew had a solution for that as well: switchaudio-osx.

I'll document the process here in case there are other people here with similar character flaws.

First, install Homebrew. You'll need Xcode for it to work. Install it from the App Store. You'll also need to run:
sudo xcode-select --install
to get the command line tools required by Homebrew.

Then you can:
brew install bluetoothconnector
brew install switchaudio-osx

Here's the command line to connect to the headphones and set them as sound output/input, configured as a shortcut key in BetterTouchTool:
/opt/homebrew/bin/BluetoothConnector -c aa-bb-cc-dd-ee-ff && /opt/homebrew/bin/SwitchAudioSource -s "🎧 Max"
In that, there are two or three things to modify: the Bluetooth address of the headphones, and the name of the headphones inside quotes. If you have an Intel Mac, the path will be /usr/local/bin and not /opt/homebrew/bin.

To get the Bluetooth address and the name, run
BluetoothConnector
without any options. You'll find your AirPods listed, with their address, and their name too. Yes, mine is "🎧 Max". Emojis do work.

BetterTouchTool has a nice option to set a HUD overlay that confirms the little script is being executed. I've set my HUD title to the headphones emoji 🎧 and the HUD Detail Text to "Max".

Screenshots with BetterTouchTool settings attached. Hope this helps.
 

Attachments

  • Screen Shot 2021-02-20 at 23.15.47.png
    Screen Shot 2021-02-20 at 23.15.47.png
    1.2 MB · Views: 124
  • Screen Shot 2021-02-20 at 23.15.34.png
    Screen Shot 2021-02-20 at 23.15.34.png
    1.3 MB · Views: 77
  • Screen Shot 2021-02-20 at 23.20.06.png
    Screen Shot 2021-02-20 at 23.20.06.png
    30.6 KB · Views: 81
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.