Scripting allows Focus to run other programs while running, for example you could integrate with Skype, Slack or another app to do something when Focus starts, stops or breaks.


Focus is scriptable, which means it can be extended to do a bunch of other cool stuff!

The two primary methods to script with Focus are BASH scripting and URL Handlers.

BASH Scripting

When Focus turns on and off, it can run custom BASH scripts which start/stop other programs, start playlists or even enable Do Not Disturb mode.

These panels are accessible in Preferences > Scripting.

Focus scripting panel

Each script has access to Focus-specific environment variables that enable you to customize the scripts based on the state of Focus.

Environment Variable Description
FOCUS_ACTIVE=0 or 1 Is Focus active or not?
FOCUS_HARDCORE_MODE=0 or 1 Is Focus in hardcore mode or not?
FOCUS_UNBLOCK_DATE=date Date when will Focus expire? (format like 2015-06-20 20:56:59 +0000)
FOCUS_INTERVAL=12345 If a timer was set, how long was it set for?
FOCUS_ACTUAL_INTERVAL=12345 Length of actual Focus session. Used in Unfocus
FOCUS_TYPE=normal or timer or schedule What kind of Focus session is this?

URL Handlers

Focus also supports being scripted from other applications, like the Browser, Terminal or Alfred.

For example, Focus can be enabled by clicking the following links:

Focus or Unfocus

Focus URL Description
focus://focus Start Focusing
focus://focus?minutes=30 Start Focusing for 30 minutes
focus://break?minutes=5 Start breaking for 5 minutes
focus://unfocus Stop Focusing
focus://unbreak Stop breaking
focus://toggle Toggle Focusing
focus://preferences Open preferences
focus://debug Show debug information \

Using URL Handlers

The easiest way to use the URL handlers is to open a new BASH shell (open /Applications/Utilities/ and type:

open focus://focus

That will start a new Focus session from the terminal.

Learn about more ways to use URL handlers.

Was this documentation helpful? Yes / No

Need help?

Contact if you have any questions about Focus.