Last active
January 25, 2018 16:27
-
-
Save mareksuscak/0762545df0f6640ab81dca620cbe18a6 to your computer and use it in GitHub Desktop.
How to Activate MacOS's "Do not Disturb" — shamelessly copied from https://github.com/johnotander/do-not-disturb
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
# Disable DND on non-Sierra | |
osascript >/dev/null <<'END' | |
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 | |
end if | |
on error | |
key up option | |
end try | |
end tell | |
end tell | |
END |
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
# Disable DND on Sierra and above | |
osascript >/dev/null <<'END' | |
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 |
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
# Enable DND on non-Sierra | |
osascript >/dev/null <<'END' | |
tell application "System Events" | |
tell application process "SystemUIServer" | |
try | |
if not (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" of menu bar 2 | |
key up option | |
end if | |
on error | |
key up option | |
end try | |
end tell | |
end tell | |
END |
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
# Enable DND on Sierra and above | |
osascript >/dev/null <<'END' | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can integrate this script with the Focus app.