| #!/bin/bash | |
| # Install sleepwatcher | |
| cd /tmp | |
| curl -O http://www.bernhard-baehr.de/sleepwatcher_2.2.tgz | |
| tar -zxvf sleepwatcher_2.2.tgz | |
| cd sleepwatcher_2.2 | |
| sudo mkdir -p /usr/local/sbin /usr/local/share/man/man8 | |
| sudo cp sleepwatcher /usr/local/sbin | |
| sudo cp sleepwatcher.8 /usr/local/share/man/man8 | |
| sudo cp config/de.bernhard-baehr.sleepwatcher-20compatibility.plist /Library/LaunchAgents | |
| sudo cp config/rc.* /etc | |
| cd .. | |
| rm -r sleepwatcher_2.2* | |
| # Add bluetooth script to /etc/rc.wakeup (the script requires root) | |
| sudo tee -a /etc/rc.wakeup <<EOF | |
| kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport | |
| kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport | |
| EOF | |
| # Load the agent to start sleepwatcher | |
| sudo launchctl load /Library/LaunchAgents/de.bernhard-baehr.sleepwatcher-20compatibility.plist |
Ditto - thanks a ton - that finally fixed the mouse issue in Yosemite.
Nice. Unloading/loading the kernel extensions manually wasn't working for me, but triggering the action via sleepwatcher has got my stupidly expensive peripherals working again. Cheers!
Thank you so much!
Exactly what I was looking for. "There must be a way to restart bluetooth on wake, that's when it's not responsive." Boom. Didn't know about sleep watcher.
excellent script man thanks a lot
Great script - thanks for sharing!
Also, for those using homebrew, sleepwatcher can be installed via:
brew install sleepwatcherI just sent in my mac to get a host of issues fixed, this bluetooth sleep issue being the most critical that wasn't an obvious easy hardware replacement. It came back with the issue still there, but this fixes it (I used brew.)
I installed sleepwatcher via homebrew, but it won't run automatically when my iMac wakes up. Do I need to take an extra step to make the homebrew app run automatically upon wakeup? Thanks.
Thank you very much. A simple cost-effective solution to a major Bluetooth failing on Mac Yosemite.
@gh91745, you have to add it to your launchd startup files. These instructions are given when you install sleepwatcher via Homebrew:
To have launchd start sleepwatcher at login:
ln -sfv /usr/local/opt/sleepwatcher/*.plist ~/Library/LaunchAgents
This will load sleepwatcher automatically when you login the first time. To load it immediately, run the following command (also provided during the Homebrew install):
launchctl load ~/Library/LaunchAgents/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist
Thanks a lot!!
Thanks so much for making this gist.
Much appreciated!