Skip to content

Instantly share code, notes, and snippets.

@r10r
Last active October 27, 2024 18:55
Show Gist options
  • 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