59

A case in point: I have Bluetooth headphones connected to my MacBook Pro, I close the lid and want to connect headphones to my iPhone. I can't do that because the MBP ↔ headphones connection is still active.

How do I configure macOS so that Bluetooth is turned off or Bluetooth connections are disconnected whenever machine goes to sleep?

I'm using macOS Mojave 10.14.5.

abEnigma
  • 34
  • 5
syntagma
  • 9,758
  • 12
  • 37
  • 53

6 Answers6

67

I created a little menubar app which turns off bluetooth when your Mac is sleeping (it's free). Hope it helps!

odlp
  • 821
  • 1
  • 6
  • 5
  • 1
    That's really helpful! – Ahmed Mahmoud Jun 22 '21 at 14:20
  • 1
    This is really cool. One question though, is it possible to get the Mac to reconnect headphones after waking up? For me, the BT adapter is enabled again, but previous connections are not re-established. – JHH Sep 24 '21 at 12:48
  • 2
    @JHH from my experience I think it depends on the device unfortunately - I have power cycle my Bose headphones to get them to scan & reconnect. – odlp Sep 29 '21 at 07:53
  • Seems to be working for me as well! Now I don't need to worry about millions of things that are using bluetooth that prevent mac from going to sleep anymore! – Pencilcheck Jan 18 '23 at 16:46
  • 1
    For the lazy, you can install this with `brew install bluesnooze`. – rattray Jan 24 '23 at 15:52
28

You could install blueutil and SleepWatcher via homebrew and set a .sleep code to do "/usr/local/bin/blueutil -p 0" when going to sleep mode.

To use SleepWatcher, make a shell script in your home directory named .sleep and give it permission with the chmod command.

You also can do a .wake code to turn bluetooth back on with blueutil -p 1

You can find out how to use sleepwatcher here

Edd Growl
  • 2,514
  • 6
  • 20
  • 36
  • No need to use AppleScript, you can use Bash commands directly in the `.sleep`/`.wake` files. – syntagma Jul 24 '19 at 06:05
  • 1
    Good catch, just edited my answer ! – Edd Growl Jul 25 '19 at 13:12
  • I'm having the same problem with Mac 2016/17 but not with my MacBook late 2013 which I strongly feel is superior device. Is there a way to only turn the audio Bluetooth off when the lid is closed so Bluetooth mouse or keyboard can wake it up? – awm Jun 25 '21 at 02:19
  • 1
    It's actually ~/.wakeup file – Xiangyu Oct 27 '22 at 13:31
8

In addition/as an update to Edd Growl's answer, this post on MacRumors includes making the files executable and a new path for blueutil that I needed to get it working on my M1 MacBook:

brew install sleepwatcher blueutil
echo "$(which blueutil) -p 0" > ~/.sleep
echo "$(which blueutil) -p 1" > ~/.wakeup
chmod 755 ~/.sleep ~/.wakeup
brew services restart sleepwatcher

They've removed the option to disable waking by Bluetooth from Monterey (12.2.1) so this was the only solution that worked for me.

FusionFox
  • 416
  • 3
  • 4
7

I created a script that does all of what @edd-growl mentions above, for you. https://github.com/alb12-la/KBOS

Alberto Lerdo
  • 71
  • 1
  • 1
6

You can automate this using BetterTouchTool - automations (https://folivora.ai/):

configuration

note: Don't be afraid to pay $20 for the whole tool, it will pay for itself in no time. The tool is must have for anyone working seriously on macos in my opinion as it adds so many features missing in standard macos.

mmmmmm
  • 28,660
  • 17
  • 84
  • 140
Petr
  • 61
  • 1
  • 1
  • Hi! I don't see such an option in my licensed copy of BTT. Can you help me make this change? – Abhishek Jain May 06 '22 at 07:46
  • @AbhishekJain Please specify what you don't see - Automations or Enable/Disable Bluetooth? You can also check folivora forums/manual for help, rather keep this focused around answers themselves. – Petr May 10 '22 at 08:11
2

I just created an app that allows you to add any paired device to a list that will be connected / disconnected when your Mac goes to sleep / wakes up - here is a link to App store. I am using it specifically for this case with headphones but of course it can be used for any other purposes.

Misternewb
  • 121
  • 1