Skip to content

Instantly share code, notes, and snippets.

@paulrudy
Created January 15, 2021 18:01
Show Gist options
  • Save paulrudy/822d1fd30ab18ff619ec77c45daf7629 to your computer and use it in GitHub Desktop.
Save paulrudy/822d1fd30ab18ff619ec77c45daf7629 to your computer and use it in GitHub Desktop.
Determine whether Do Not Disturb (DND) is enabled (MacOS 11.x Big Sur)
#!/bin/zsh
dnd_enabled=$(plutil -extract dnd_prefs xml1 -o - ~/Library/Preferences/com.apple.ncprefs.plist | xpath -q -e 'string(//data)' | base64 -D | plutil -convert xml1 - -o - | xpath -q -e 'boolean(//dict/key[text()="enabled"])')
echo $dnd_enabled
# An output of 1 means Do Not Disturb is enabled, and 0 means it's disabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment