Focus is an extremely powerful productivity tool for Mac.
Focus aims to work the way you work, which is why we offer Scripting so you can integrate Focus into other applications, and other applications into Focus.
Focus Scripting enables productivity automation and is one of the most advanced ways to level up your productivity.
Focus Scripting lets you automate your perfect productivity environment with 1-click. Spend a little time getting it set up, and you'll reap the rewards every Focus session.
Focus is great at calling other applications, and letting other applications call it. This makes it straightforward to integrate it and create the productivity routine of your dreams.
There are two main ways to automate productivity with Focus Scripting:
- Scripting Outside Focus — call Focus from other apps
- Scripting Inside Focus — call other apps from Focus
Calling Focus from other applications is easy using Apple URL Handlers.
For example, if you have Focus installed—clicking these links will start and stop Focus—from your web browser!
Here's the HTML to perform this:
<a href="focus://focus">Focus</a> or <a href="focus://unfocus">Unfocus</a>
Notice instead of http:// or https:// links, they're focus:// links. This is how you call Focus from other applications.
It also works from the Terminal, turning Focus on
Turn Focus off
You can also start a timed Focus session
Or just toggle between Focus and Unfocus states.
Here are all the commands you can use to interact with Focus from other applications:
|focus://focus?minutes=30||Start Focusing for 30 minutes|
|focus://break?minutes=5||Start breaking for 5 minutes|
|focus://debug||Show debug information|
To learn more, read Scripting Focus with URL handlers.
Note: In Ventura, Apple changed the default shell from BASH to ZSH, which means Focus URLs should be wrapped in quotes, especially when query parameters are used.
Focus can also call other apps. To get started, click the Focus menubar icon, then select Preferences in the drop-down menu.
Then select the Scripting panel from Focus Preferences, Focus should look like this:
Focus Scripting lets you run any BASH command when Focus starts, stops, starts breaking or stops breaking.
This lets you play custom sounds, display notifications, hook into other apps—anything you can think of.
BASH scripting literally lets you do anything, read more to learn how.
To learn how to create BASH scripts for Focus, consult your favorite programmer, AI assitant or app documentation. Also, you can email [email protected] and we'll be happy to help.
Every Focus BASH Script gets called with environment variables to help give you the current state of Focus.
Here they are below, you can access them like
|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?|
Note: when spawning a new BASH shell, Focus does not include your normal
bashrc environment. Typically specifying the full path of scripts and executables is a good way for things to work despite not being in your normal environment.
Just like other Focus settings, you can import, export and reset Focus scripting back to defaults by accessing the settings cog at the bottom of the preferences screen.
Productivity Automation is incredibly simple, whether you're trying to create your perfect environment, or hook Focus into your existing productivity workflow—Focus Scripting has everything you need.
Now that you've learned Focus Automation, learn some additional features like Drag and Drop to quickly add blocked distractions, Password Mode to lock preferences, and a Global Hotkey that lets you start a Focus session from anywhere.