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.

Revisions

  1. paulrudy created this gist Jan 15, 2021.
    7 changes: 7 additions & 0 deletions is_dnd_enabled.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/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.