Search code examples
macosshellapplescriptmacos-montereydo-not-disturb

How to read do not disturb using applescript?


I am trying to read status of do not disturb or dnd using applescript.

For some reason, it always return "1" no matter what if the dnd is on or off.

do shell script "defaults -currentHost read ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb"

Stack Editor: Script Editor to create and run the script OS: macOS Monterey


Solution

  • Solution for Monterey

    #!/bin/bash
    defaults read com.apple.controlcenter "NSStatusItem Visible FocusModes"
    

    It returns 1 if "Do Not Disturb" is enabled, 0 otherwise.