Skip to content

Instantly share code, notes, and snippets.

@DamnedFacts
Created March 6, 2013 22:53
Show Gist options
  • Save DamnedFacts/5103958 to your computer and use it in GitHub Desktop.
Save DamnedFacts/5103958 to your computer and use it in GitHub Desktop.
-- Uses cleaner syntax than common solutions for toggling the state of the Notification Center in Mac OS X Mountain Lion (10.8)
set notificationStatus to do shell script "defaults -currentHost read com.apple.notificationcenterui doNotDisturb"
if notificationStatus is equal to "1" then
do shell script "defaults -currentHost write com.apple.notificationcenterui doNotDisturb -boolean false"
do shell script "defaults -currentHost delete com.apple.notificationcenterui doNotDisturbDate"
do shell script "launchctl stop com.apple.notificationcenterui.agent"
else
do shell script "defaults -currentHost write com.apple.notificationcenterui doNotDisturb -boolean true"
set theDate to quoted form of (do shell script "date +\"%Y-%m-%d %I:%M:%S +0000\"")
do shell script "defaults -currentHost write com.apple.notificationcenterui doNotDisturbDate -date " & theDate
do shell script "launchctl stop com.apple.notificationcenterui.agent"
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment