Integrate automatic Do Not Disturb with Session on Mac

Philip Young

Important!

As of macOS 11 or later, it is better to rely on Apple Shortcut to turn on/off Do Not Disturb instead of relying on this Applescript hack.

You can follow it here.

Introduction

Setting up Do Not Disturb without AppleScript experience is the easiest way to keep you stay focused and out of distraction. Instead of turning it on/off manually, Session can help you automate it.

There are 5 steps to follow:

  1. Add Do Not Disturb Cresent Moon Icon on Menu Bar,
  2. enable Do Not Disturb keyboard shortcut on your Mac,
  3. download the necessary file, and
  4. put it on Session script folder.
  5. Done!

Let's get started.

1. Add Do Not Disturb Cresent Moon on Menu Bar

If you have Cresent Moon icon (Do Not Disturb) on menu bar, you can skip this step. Otherwise, please follow the gif: Keyboard shortcut DND

  1. Press control icon
  2. Open Do Not Disturb
  3. Hold the Do Not Disturb text header into menu bar
  4. Make sure the Cresent Moon icon exists

2. Enable toggling Do Not Disturb with keyboard shortcut

  1. Go to Mac's System Preferences > Keyboard > Shortcuts > Mission control
  2. Enable Turn Do Not Disturb On/Off checkbox.
  3. Double click the input beside the "Turn Do Not..." text Keyboard shortcut DND
  4. Press CMD + SHIFT + OPT + CTRL + D key combination while the input is focused.
  5. Try pressing your new keyboard shortcut and see if Do Not Disturb is turned on/off

Great! Now you can toggle Do Not Disturb with keyboard shortcut! What we need to do next is to tell Session to press that keyboard automatically when Session has started, and when you have stopped working.

3. Download pre-made AppleScript file that turn on and off Do Not Disturb

You're going to download a code to toggle the Do Not Disturb. It basically does this:

  • When Session has started, we check if Do Not Disturb is off. If yes, press CMD + SHIFT + OPT + CTRL + D keyboard shortcut with code.
  • When you stopped working, we check if Do Not Disturb is on. If yes, press CMD + SHIFT + OPT + CTRL + D to turn off the Do Not Disturb.

Download the pre-made AppleScript code here

4. Extract the zip file on Session's AppleScript folder.

  1. Extract the files session_start.scpt, session_end.scpt, andstop_working.scpt on your Mac Desktop temporarily.
  2. Copy both files.
  3. Put both file on Session's AppleScript folder. The folder is accessible by clicking a open appple script folder on Session's setting page.

Open AppleScript folder gif

5. Check if the AppleScript is working

  1. Go back to Session Preferences > Automation (AppleScript),
  2. check Session start checkbox,
  3. check Session end checkbox,
  4. check Stop working checkbox,
  5. press Test session start,
  6. make sure it turn on Do Not Disturb.
  7. press Test session end,
  8. make sure it turn on Do Not Disturb.
  9. Press Test stop Working,
  10. make sure it turn off Do Not Disturb.

If it didn't ran, make sure you have put the script in correct location. Refer to screenshot above. Otherwise, you can contact us on our email

6. Enjoy undistracted working

Congratulations! Now Session will turn on and off Do Not Disturb while you're working :)

If you want to quit distracing app like Slack, play spotify playlist—consider learning and writing your first AppleScript. We've made a tutorial for you!

© Copyright 2020-2024 Translucent LLC