No notifications, full screen, no screen saver applescript

flickr photo shared by David Allen Wizardgold under a Creative Commons ( BY-ND ) license

I saw this exchange on Twitter yesterday.

It seemed like something I could do in Applescript for those on the Mac. This example works in 10.10.4 (and could form the basis for something similar that’d work in other OS versions).

Note, at the moment it doesn’t turn things back on afterwards. If I see any interest, I’ll add that kind of thing. Currently, it also assumes you want Chrome to go full screen but it’d be easy to change that to whatever application you want.

To try it out, open up Applications>Script Editor. Cut and paste this in and hit the play button. If it does what you want, you can save it as an App and then just click it to launch.

do shell script "defaults write ~/Library/Preferences/ByHost/*.plist doNotDisturb -boolean true"
set theDate to quoted form of (do shell script "date +\"%Y-%m-%d %I:%M:%S +0000\"")
do shell script "defaults write ~/Library/Preferences/ByHost/*.plist doNotDisturbDate -date " & theDate
do shell script "killall NotificationCenter"

tell application "Google Chrome" to activate
tell application "System Events"
	keystroke "f" using {control down, command down}
	tell screen saver preferences to set delay interval to 0
end tell