Enabling Do Not Disturb mode

How to enable Do Not Disturb mode while Focus is running on your Mac.

Focus is extremely flexible because of its BASH scripting capabilities. Because of this, it's easy to add new features & and integrations that weren't originally built into the software.

For example, this is how you turn on Mac OS X's "Do not disturb" mode when Focus is enabled.

Enabling Do Not Disturb mode with scripting

In Focus preferences, go to the "Scripting" panel.

Under the "Focus" section, copy the following three lines and copy them into the text box.

defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean true
defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturbDate -date "`date -u +\"%Y-%m-%d %H:%M:%S +000\"`"
killall NotificationCenter

That's it!

Now when Focus runs, it will execute those three commands which will turn "Do Not Disturb" mode on.

Here's a quick explanation of each line:

  1. Enable Do Not Disturb mode
  2. Set the date for when to turn Do Not Disturb off (defaults to tomorrow)
  3. Apply changes by relaunching notification center

Disabling Do Not Disturb with scripting

Turning Do Not Disturb mode off is just as easy.

In Focus preferences, go to the "Scripting" panel.

Under the "Unfocus" section, copy the following three lines and copy them into the text box.

defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean false
killall NotificationCenter

This will turn Do Not Disturb mode back on when Focus is done with a session.

Having a hard time staying on task because of distractions? Focus is an app for your Mac computer that helps you stay on track. It blocks things that can distract you so you can get your work done. Try Focus and see how much better you can do!
Download Focus
← Back to blog
Focus Productivity on April 23, 2015