Forked from Sanabria/toggle-applescript-dnd. scpt
Created
September 14, 2021 00:00
-
-
Save lvnilesh/18fc427141ae7430ccc2589a4cefc970 to your computer and use it in GitHub Desktop.
Applescript: Toggle Do Not Disturb mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Note 1: The 1 after menu bar may need to be changed to 2 when using multiple monitors *) | |
(* Note 2: For 10.11 and newer “NotificationCenter” is now spelled “Notification Center”*) | |
tell application "System Events" | |
tell application process "SystemUIServer" | |
try | |
if exists menu bar item "Notification Center, Do Not Disturb enabled" of menu bar 1 of application process "SystemUIServer" of application "System Events" then | |
(* It is disabled *) | |
display dialog "Notifications will be turned on" buttons {"Got it"} default button 1 | |
key down option | |
click menu bar item "Notification Center, Do Not Disturb enabled" of menu bar 1 | |
key up option | |
else | |
(* It is enabled *) | |
display dialog "Notifications will be turned off" buttons {"Got it"} default button 1 | |
key down option | |
click menu bar item "Notification Center" of menu bar 1 | |
key up option | |
end if | |
on error | |
key up option | |
end try | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment