Skip to content

Instantly share code, notes, and snippets.

@ZoltonMD
Created October 24, 2017 06:23
Show Gist options
  • Save ZoltonMD/983471a1cf828ebf0e4cea7b076f6b7c to your computer and use it in GitHub Desktop.
Save ZoltonMD/983471a1cf828ebf0e4cea7b076f6b7c to your computer and use it in GitHub Desktop.
macos bluetooth restart
#!/bin/bash
# restart:
# > ./restart_bluetooth.sh
# turn bluetooth on:
# > ./restart_bluetooth.sh 1
# turn bluetooth off:
# > ./restart_bluetooth.sh 0
output="Bluetooth restarted";
if [ $# -eq 1 ]; then
if [ $1 -eq "1" ]; then
sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState 1
output="Bluetooth is on";
elif [ $1 -eq "0" ]; then
sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState 0
output="Bluetooth is off";
fi;
fi;
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
echo $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment