79

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.

6 Answers 6

34

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

4
  • No need to use AppleScript, you can use Bash commands directly in the .sleep/.wake files.
    – syntagma
    Commented Jul 24, 2019 at 6:05
  • 1
    Good catch, just edited my answer !
    – Edd Growl
    Commented Jul 25, 2019 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
    Commented Jun 25, 2021 at 2:19
  • 1
    It's actually ~/.wakeup file
    – Xiangyu
    Commented Oct 27, 2022 at 13:31
85

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

5
  • 2
    That's really helpful! Commented Jun 22, 2021 at 14:20
  • 2
    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
    Commented Sep 24, 2021 at 12:48
  • 3
    @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
    Commented Sep 29, 2021 at 7:53
  • 1
    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! Commented Jan 18, 2023 at 16:46
  • 6
    For the lazy, you can install this with brew install bluesnooze.
    – rattray
    Commented Jan 24, 2023 at 15:52
10

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.

9

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.

3
  • Hi! I don't see such an option in my licensed copy of BTT. Can you help me make this change? Commented May 6, 2022 at 7: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
    Commented May 10, 2022 at 8:11
  • 2
    @AbhishekJain on left "All Apps", on top "Automations & Named & Other Triggers", then within that press "+" and make two triggers, and then the automation Commented May 6, 2023 at 20:50
7

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

3

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.

You must log in to answer this question.

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