Created
September 13, 2019 12:13
-
-
Save DrewDouglass/b9277971e01eb515e66ea675cb174251 to your computer and use it in GitHub Desktop.
Toggle Do Not Disturb Mac OS Command Line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://apple.stackexchange.com/a/303400 | |
set -eou pipefail | |
# From https://heyfocus.com/enabling-do-not-disturb-mode and | |
# https://apple.stackexchange.com/questions/145487 | |
if [[ $(defaults -currentHost read ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb) -eq 0 ]]; then | |
defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean true | |
defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturbDate -date "`date -u +\"%Y-%m-%d %H:%M:%S +000\"`" | |
killall NotificationCenter | |
echo "Do Not Disturb is enabled. Run $0 to turn it off (OS X will turn it off automatically tomorrow)." | |
else | |
defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean false | |
killall NotificationCenter | |
echo "Do Not Disturb is disabled. Run $0 to turn it on again." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment