Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install sleepwatcher to restart bluetooth & friends
brew install sleepwatcher
sudo cp /usr/local/Cellar/sleepwatcher/2.2/de.bernhard-baehr.sleepwatcher-20compatibility.plist /Library/LaunchAgents/
sudo cp /usr/local/Cellar/sleepwatcher/2.2/etc/sleepwatcher/rc.* /etc/
# Add bluetooth script to /etc/rc.wakeup (the script requires root)
sudo tee -a /etc/rc.wakeup <<EOF
## Restart blued & load/unload bluetooth driver.
function msg() {
what="\$(tr '[:lower:]' '[:upper:]' <<< \${foo:0:1})\${foo:1}"
echo ">> \${what}ing \$1...";
function __blued() {
msg "blued" "\$1";
sudo launchctl \$1 /System/Library/LaunchDaemons/
function __driver() {
msg "bluetooth driver" "\$1";
sudo kext\$1 -b
__blued "unload"
__driver "unload"
sleep 2;
__driver "load";
__blued "load"
# Load the agent to start sleepwatcher
sudo launchctl load /Library/LaunchAgents/de.bernhard-baehr.sleepwatcher-20compatibility.plist

This comment has been minimized.

Copy link

@inspiredearth inspiredearth commented Jul 16, 2015

Thanks for this. Very helpful for my MBP Bluetooth woes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment