Setup session automation on Mac with AppleScript

Philip Young

Session automation on Mac is powered by AppleScript. This means you need to understand a bit of code to unlock it's full potential. If you don't know about Session automation yet, you can learn more from Automate your workflow with Session Automation.

If you don't want to dabble with code and just want to turn on Do Not Disturb on and off—follow this guide to turn on/off Do Not Disturb with Session.

If you're up with the challenge, you can learn to write your first AppleScript.

Now, let's dissect how to integrate AppleScript you wrote or download with Session.

Important!

It's now possible to use Apple Shortcuts (the same one on iOS) on Monterey on above. This way you can share the shortcut between macOS and iOS. Take a look at here.

1. Automation file name

There's 5 scenarios where automation ran. They are:

  1. Your session has started: session_start.scpt
  2. Your paused session: session_pause.scpt
  3. Your unpaused session: session_unpause.scpt
  4. Your unpaused session: session_went_too_long.scpt
  5. Your session has ended: session_end.scpt
  6. Your break has started: break_start.scpt
  7. Your unpaused session: break_went_too_long.scpt
  8. Your break has ended: break_end.scpt
  9. Called whenever session_end or break_end not called. Example, from abandon Session : stop_working.scpt

p.s. .scpt is a file extension for AppleScript (like .mp3 for Music).

What you probably use is session_start, session_end, stop_working and possibly break_start.

Session will run AppleScript you've made if the script with matching file name above exists on Session script folder. Otherwise, it'll be ignored.

2. Put the script you've wrote inside Session folder

You can put the script you've wrote, rename the script while filename above (refer to #1) inside Session's user script folder (you can open the folder location by clicking a button on Session's setting page).

Open AppleScript folder button

Move the script you have wrote / download to com.philipyoungg.session folder below:

AppleScript inside folder

3. Check if the AppleScript is working

  1. Go back to Session Preferences > Automation (AppleScript),
  2. check Session start checkbox,
  3. check Stop working checkbox,
  4. press Test session Start,
  5. make sure it turn on Do Not Disturb.
  6. Press Test stop Working,
  7. 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 me on my email

4. Enjoy your automation!

Congratulations! Now you've automated your workflow based on Session current state!

© Copyright 2020-2024 Translucent LLC