Created
September 18, 2014 13:08
-
-
Save Zettt/fd9979100d4603e548d6 to your computer and use it in GitHub Desktop.
Toggle Notification Center's Do Not Disturb on OS X Yosemite. Brought to you by Automator.
This file contains 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
-- Toggle Notification Center's DND on Yosemite | |
tell application "System Events" | |
option key down | |
delay 0.1 | |
try | |
click menu bar item "Notification Center" of menu bar 2 of application process "SystemUIServer" | |
end try | |
try | |
click menu bar item "NotificationCenter, Do Not Disturb enabled" of menu bar 2 of application process "SystemUIServer" | |
end try | |
option key up | |
end tell |
Another variation to get El Capitan to work.....
from ... http://applehelpwriter.com/2014/12/10/applescript-toggle-notification-centre-yosemite/comment-page-1/
tell application "System Events"
tell application process "SystemUIServer"
try
if exists menu bar item "Notification Center, Do Not Disturb enabled" of menu bar 2 of application process "SystemUIServer" of application "System Events" then
key down option
click menu bar item "Notification Center, Do Not Disturb enabled" of menu bar 2
key up option
else
key down option
click menu bar item "Notification Center" of menu bar 2
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
The ordering of the menu bars of SystemUIServer seems to be different on each person's computer. To avoid that, I wrote this: