Skip to content

Instantly share code, notes, and snippets.

@r10r
Last active February 10, 2022 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r10r/bdf3f1e64fb0d683a5db5b9691f8aedf to your computer and use it in GitHub Desktop.
Save r10r/bdf3f1e64fb0d683a5db5b9691f8aedf to your computer and use it in GitHub Desktop.
macOS sleepwatcher scripts
# Turn of bluetooth before sleep
/usr/local/bin/blueutil -p 0
# Enable bluetooth again.
/usr/local/bin/blueutil -p 1
# Turn of the internal display if the external monitor is connected.
if system_profiler SPDisplaysDataType -json | grep -q PL2792UH; then
/usr/local/bin/brightness 0
fi

Prevent Bluetooth Device from Waking Mac from Sleep

  • Option is removed in macOS Monterrey 12.0.1

https://support.apple.com/en-ca/guide/mac-help/mchlp2664/12.0/mac/12.0

A fix is disabling bluetooth with blueutil on sleep and enable it back again on wake using sleepwatcher.

From https://forums.macrumors.com/threads/monterey-bluetooth-wake-issue.2319613/page-2?post=30819437#post-30819437

brew install sleepwatcher && brew install blueutil
echo "/usr/local/bin/blueutil -p 0" > ~/.sleep && echo "/usr/local/bin/blueutil -p 1" > ~/.wakeup
chmod 755 ~/.sleep && chmod 755 ~/.wakeup
brew services restart sleepwatcher
rm ~/.sleep && rm ~/.wakeup
brew uninstall sleepwatcher && brew uninstall blueutil
brew services cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment