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

Enabling Do Not Disturb mode

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.



Was this blog post helpful? Yes / No
Posted on April 24, 2015


« Back to blog archive

Start a free 7-day email course to get the most out of Focus: