Skip to main content
2 of 2
Updated with more instruction
webmarc
  • 1.7k
  • 13
  • 18

You can just setup a global keyboard shortcut for it in System Preferences -> Keyboard -> Shortcuts -> Mission Control

Or if you definitely want it from the command line, an applescript to do this (assuming you setup the keyboard shortcut to use cmdshiftoptctrlD.

Note that you still MUST setup a keyboard command in System Preferences for this to work.

Put the below script into a file, say, ~/dnd.applescript

ignoring application responses
    tell application "System Events" to keystroke "D" using {command down, shift down, option down, control down}
end ignoring

Now you can run osascript ~/dnd.applescript from the command line to toggle your DND setting.

Screencap: Keyboard shortcut modification in System Preferences

webmarc
  • 1.7k
  • 13
  • 18