Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save a7madgamal/9d3518a62c21477a92be461fbd652533 to your computer and use it in GitHub Desktop.
Save a7madgamal/9d3518a62c21477a92be461fbd652533 to your computer and use it in GitHub Desktop.
Change Do not disturb DND setting on Macos Big Sur using the terminal

defaults read com.apple.ncprefs.plist dnd_prefs

turn on: defaults write com.apple.ncprefs.plist dnd_prefs -data 62706C6973743030D60102030405060708080A08085B646E644D6972726F7265645F100F646E64446973706C6179536C6565705F101E72657065617465644661636574696D6543616C6C73427265616B73444E445875736572507265665E646E64446973706C61794C6F636B5F10136661636574696D6543616E427265616B444E44090808D30B0C0D070F1057656E61626C6564546461746556726561736F6E093341C2B41C4FC9D3891001080808152133545D6C828384858C9499A0A1AAACAD00000000000001010000000000000013000000000000000000000000000000AE

turn off: defaults write com.apple.ncprefs.plist dnd_prefs -data 62706C6973743030D5010203040506070707075B646E644D6972726F7265645F100F646E64446973706C6179536C6565705F101E72657065617465644661636574696D6543616C6C73427265616B73444E445E646E64446973706C61794C6F636B5F10136661636574696D6543616E427265616B444E44090808080808131F3152617778797A7B0000000000000101000000000000000B0000000000000000000000000000007C

@gqbre
Copy link

gqbre commented Mar 2, 2021

not working ?

@d-d
Copy link

d-d commented Mar 9, 2021

view status:
defaults read com.apple.controlcenter "NSStatusItem Visible DoNotDisturb"

@gqbre
Copy link

gqbre commented Mar 9, 2021

view status:
defaults read com.apple.controlcenter "NSStatusItem Visible DoNotDisturb"

The domain/default pair of (com.apple.controlcenter, NSStatusItem Visible DoNotDisturb) does not exist

@luckman212
Copy link

#!/usr/bin/env bash

# reads DND status
# there can be a delay of up to ~10s before changes are reflected

PLIST=~/Library/Preferences/com.apple.controlcenter.plist
MODE_DND=$(plutil -extract "NSStatusItem Visible DoNotDisturb" raw -o - -- $PLIST)
MODE_FOCUS=$(plutil -extract "NSStatusItem Visible FocusModes" raw -o - -- $PLIST)

case $1 in
-d|--debug) cat <<EOF
  DND: $MODE_DND
FOCUS: $MODE_FOCUS
EOF
esac

if [[ $MODE_FOCUS == false ]] && [[ $MODE_DND == false ]]; then
    echo "off"
else
    echo "on"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment