Skip to content

Instantly share code, notes, and snippets.

@joshgachnang
Created March 1, 2017 17:59
Show Gist options
  • Save joshgachnang/cf376c9fe75f7702add292f3befa4500 to your computer and use it in GitHub Desktop.
Save joshgachnang/cf376c9fe75f7702add292f3befa4500 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script will turn on and off do not disturb mode in OSX. I use a cronjob to trigger this during my scheduled focus times.
if [ "$1" == "off" ]; then
defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean false
killall NotificationCenter
echo "Disabled Do Not Disturb mode"
elif [ "$1" == "on" ]; 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 "Enabled Do Not Disturb mode"
else
echo "Usage: donotdisturb.sh [on|off]"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment