Prevent auto-pairing for certain devices (Bluetooth)
I have a Early 2011 Macbook Pro 13" running OS X 10.10.1 (Yosemite).
At work, I have a Apple Magic Trackpad and an Apple Wireless Keyboard, both which use Bluetooth. When I get to work, my Mac automatically connects to both of them (if Bluetooth is on).
At home, I have a Belkin F8Z492-P Bluetooth Audio Adapter hooked up to my stereo (sorry, no product page available). If Bluetooth is on, my audio will automatically be routed to the Bluetooth adapter (which is something I rarely want).
How can I make OS X automatically connect to my trackpad and keyboard at work but not automatically connect to the bluetooth audio adapter at home?
Currently, I shut Bluetooth off when I get home, but I'd like to avoid toggling Bluetooth when I get home/when I get to work, since it is quite annoying to start typing on the wireless keyboard and have nothing happen, or not have audio when I get home.
If this is not possible, can I prevent OS X from switching my audio automatically when connecting to the Bluetooth audio adapter?
Solution 1:
I had the same problem and FINALLY found a workable solution. Run this in your terminal. After this you just need to manually connect to your bluetooth audio system.
sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist DontPageAudioDevices 1
Solution 2:
Adding MAC address of a device to IngoredDevices disables auto connect of Bluetooth. To do so follow these steps:
-
disable Bluetooth.
-
find MAC address in DeviceCache with following command
sudo defaults read /Library/Preferences/com.apple.Bluetooth.plist DeviceCache
-
add MAC address to IgnoredDevices
sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist IgnoredDevices -array-add '<MAC ADDRESS>'
-
print contents of the file, you should see there MAC address which has been added in step 3
sudo defaults read /Library/Preferences/com.apple.Bluetooth.plist IgnoredDevices
-
restart your Mac
-
enable Bluetooth
This should work on Mojave and Catalina.
Solution 3:
This is a bit of a long shot, but at home go into System Preferences > Sound > Output and manually select the Default option (Usually Speakers).
This means that OS X will re-prioritise so that when the Belkin F8Z492-P Bluetooth Audio Adapter becomes available, you'd rather use the default option.
Then, when you want to use it, select it via the AirPlay menu (if possible) because that doesn't affect OS X's priorities. If it is not available via the AirPlay menu then you will just have to manually switch forward and back with the System Preferences app, unless you feel like diving into some AppleScripting.
Solution 4:
I have Bluetooth headphones for which none of the previous solutions worked. By headphones were pretty cheap and I discovered that my Macbook Pro 2019's initial connection for auto-pairing was terrible (audio consistently skipped), but after disconnecting and reconnecting it was fine. I originally came to this post before Big Sur and back then adding my headphones’ MAC address to the list of IgnoredDevices (see answer from Kiyose) worked. But after Big Sur (currently on 11.4), neither DontPageAudioDevices
nor adding to IgnoredDevices
worked for me. This could be due to the shoddy implementation of Bluetooth on my cheap headphones, probably not uniquely due to Big Sur. In fact, connecting to my headphones totally messed up the Bluetooth module to the point where it couldn’t be turned on/off, and none of the traditional solutions (e.g. reset bluetooth module, Bluetooth → Debug, delete .plist
files, etc.), other than reboot, could fix it. Obviously didn't want to have to reboot my Mac every time I wanted to connect headphones. So I came up with this solution for Bluetooth devices that are so problematic that you need to disconnect and unpair every time. This solution requires blueutil.
- Install
blueutil
:
homebrew install blueutil
- Use Automator (or any similar application) → Quick Actions → Run Shell Script with workflow set to receive no input and work in any application. Create two scripts that contain
blueutil
commands to pair/connect and unpair/disconnect to your bluetooth device. Note I found I needed to include full path for Automator's shell to findblueutil
, perhaps because it is not being run interactively. You can confirm your scripts are working by monitoring System Preferences → Bluetooth and using the Run button in Automator, before proceeding to the next step.
# pair/connect
/usr/local/bin/blueutil --pair <MAC_ADDRESS_OF_BT_DEVICE>
sleep 5
/usr/local/bin/blueutil --connect <MAC_ADDRESS_OF_BT_DEVICE>
# unpair/disconnect
/usr/local/bin/blueutil --disconnect <MAC_ADDRESS_OF_BT_DEVICE>
/usr/local/bin/blueutil --unpair <MAC_ADDRESS_OF_BT_DEVICE>
- Set up keyboard bindings to the Automator quick actions with System Preferences → Keyboard → Shortcuts → Services. The new actions should be under General if you set to receive no input.
Now when you turn your bluetooth device on, simply use your keyboard shortcut to pair/connect. And when you're done, turn it off and run the disconnect/unpair action.