
IMPORTANT: Please note that running these scripts for the first time may require accessibility permission for the app which runs the scripts. They also don't require any key bindings or machine GUID to work.

Run $0 to turn it on again."īuilding on answers from James and Zsolt, I've created a couple of scripts to turn on or off (not toggle) DND state. Run $0 to turn it off (OS X will turn it off automatically tomorrow)."ĭefaults -currentHost write ~/Library/Preferences/ByHost/ doNotDisturb -boolean falseĮcho "Do Not Disturb is disabled. If ] thenĭefaults -currentHost write ~/Library/Preferences/ByHost/ doNotDisturb -boolean trueĭefaults -currentHost write ~/Library/Preferences/ByHost/ doNotDisturbDate -date "`date -u +\"%Y-%m-%d %H:%M:%S +000\"`"Įcho "Do Not Disturb is enabled. Here is an example of how to do that: #!/bin/bash Now you could easily wrap this up as a script to enable or disable "Do Not Disturb" as a script that would work on anybody's machine regardless of system preferences.

You can simplify the answer that razvanz provided by using the -currentHost argument to the defaults command.Įnable Do Not Disturb: defaults -currentHost write ~/Library/Preferences/ByHost/ doNotDisturb -boolean trueĭefaults -currentHost write ~/Library/Preferences/ByHost/ doNotDisturbDate -date "`date -u +\"%Y-%m-%d %H:%M:%S +0000\"`"ĭisable Do Not Disturb: defaults -currentHost write ~/Library/Preferences/ByHost/ doNotDisturb -boolean false
