Focus is a Mac app that blocks distracting websites like Facebook and Reddit. Download Now

Scripting

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://unfocus Stop Focusing
focus://toggle Toggle Focusing
focus://preferences Open preferences
focus://debug Show debug information


Learn about more ways to use URL handlers.

Watch Tutorial

Watch a tutorial on how to use advanced scripting to run custom actions when Focus turns on and off.

Need help?

Contact support@heyfocus.com if you have any questions about Focus.