1

I'm dual booting Win10 / OSX via bootcamp on a Macbook Pro touchbar.

When I switch to Windows, my bluetooth mouse will not connect (or with great difficulty) unless I have disabled bluetooth before shutting down OSX. I believe there is a an issue where OSX is somehow holding the bluetooth pairing of the mouse, making it problematic in Windows. If I first disable bluetooth in OSX, then Win10 connects to the mouse 100% no problems.

For this reason, I want to have a way to automatically disable bluetooth when I restart or shutdown OSX, and vice versa when OSX starts up. Then I won't be forgetting all the time to do it manually.

2
  • brew install sleepwatcher. I think it also can monitor shutdown event. Feb 10, 2020 at 6:19
  • @DavidDai - nothing on the brew site or the dev's site says anything about shutdown/restart. Are you sure this works for shutdowns?
    – Allan
    Feb 10, 2020 at 17:38

3 Answers 3

1

You can do this using two different tools:

  • Blueutil (free) which is a command line utility to control the Bluetooth radio (no native way to do do this in macOS). You can get more info from this post. However, the command (once Blueutil is installed) would be:

    $ blueutil off      ← Turns off Bluetooth radio
    
  • EventScripts allows you to run scripts/commands at certain events like shutdown, restart, your location, USB device detection and more. I've been testing this for the last few days and so far, it seems to work really well. It's not free, but at £4, it's fairly inexpensive to solve the problem.

I'd normally use launchd, however, there's no way to use it to launch a script at shutdown and the only way is to write your own shutdown hook.

0

Allan's answer no longer works on recent versions of macOS because blueutil is outdated and can't be compiled against modern SDKs. EventScripts is still available though, and instead of blueutil Applescript can be used. I modified some scripts posted on reddit to work:

bluetooth_on.scpt

tell application "System Events"
    tell process "ControlCenter"
        set BluetoothButton to menu bar item "Bluetooth" of menu bar 1
        click BluetoothButton
        delay 1
        set OnSwitch to checkbox "Bluetooth" of group 1 of window "Control Center"
        if value of OnSwitch is 0 then
            click OnSwitch
        end if
    end tell
end tell

bluetooth_off.scpt

tell application "System Events"
    tell process "ControlCenter"
        set BluetoothButton to menu bar item "Bluetooth" of menu bar 1
        click BluetoothButton
        delay 1
        set OnSwitch to checkbox "Bluetooth" of group 1 of window "Control Center"
        if value of OnSwitch is 1 then
            click OnSwitch
        end if
    end tell
end tell

Usage: osascript bluetooth_off.scpt or osascript bluetooth_on.scpt and then use these from EventScripts.

0

i need a windows version :( I using tp-link ub500 bluetooth adaptor because my onboard bluetooth stammer sounds. But ub500 won't turn off after shut down my pc. And my headset waiting for connection.

2
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 30, 2022 at 19:44
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review Nov 30, 2022 at 20:33

You must log in to answer this question.

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