Skip to content

Instantly share code, notes, and snippets.

@romashamin
Last active June 16, 2017 12:16
Show Gist options
  • Save romashamin/5a5661f430b9ddd18564282e986f5d94 to your computer and use it in GitHub Desktop.
Save romashamin/5a5661f430b9ddd18564282e986f5d94 to your computer and use it in GitHub Desktop.
Enables ‘Do Not Disturb’ for 10 min
my setDoNotDisturbON()
say "Do not disturb is on now" using "Samantha"
delay 600
my setDoNotDisturbOFF()
say "Do not disturb is off. Welcome to hell!" using "Samantha"
on setDoNotDisturbON()
tell application "System Events"
tell application process "SystemUIServer"
try
if not (exists menu bar item "Notification Center, Do Not Disturb enabled" of menu bar 1 of application process "SystemUIServer" of application "System Events") then
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
end setDoNotDisturbON
on setDoNotDisturbOFF()
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
key down option
click menu bar item "Notification Center, Do Not Disturb enabled" of menu bar 1
key up option
end if
on error
key up option
end try
end tell
end tell
end setDoNotDisturbOFF
# src: https://github.com/johnotander/do-not-disturb/blob/master/index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment