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

Scripting Focus with OS X URL Handlers

Focus supports OS X URL handlers, which means you can turn it on and off from the browser, operating system and 3rd party apps.

In the browser

For example, try clicking the links below:

Focus or Unfocus

If you have Focus installed it will turn the app on or off (you may have to click approve if a dialog comes up).

Here’s the HTML to perform this:

<a href="focus://focus">Focus</a> or <a href="focus://unfocus">Unfocus</a>

In the terminal

In the terminal, you could turn Focus on by typing

open focus://focus

Or turn Focus off

open focus://unfocus

You can also pass in a duration

open focus://focus?minutes=30&seconds=30

Or just toggle to a different state

open focus://toggle

Calendar

Focus has scheduling features, but with scripting it can also be turned on & off from your Calendar by using Automator & Calendar alarms. Here’s how:

You can skip to step 5 if you want to download the existing Focus Automator workflows. Otherwise:

  1. Open Automator and create a new Calendar Alarm workflow

    Create Focus workflows in Automator
  2. Add a new Run Shell Script action

  3. Add code to action that invokes Focus

    /usr/bin/open focus://focus
    Add run scripts that invoke Focus for automator workflow
  4. Export the action. Also create an unfocus action if required.

  5. Create a new event in Calendar with an alert type of Custom… (only works with regular Calendar events, not Google)

  6. Select Open file and Other… for the first and second options

  7. Select the exported Automator workflow from step 4 that triggers Focus

  8. Set the last option to At time of event

    Create custom alert on calendar to invoke Focus scripts

Now, when your Calendar alarm goes off, Focus will run the Automator script which will turn Focus on or off.

3rd party apps

Focus is also easy to integrate with other 3rd party apps like Alfred.

Focus integrates well with 3rd party apps like Alfred

Download the Alfred workflow and quickly enable or disable Focus with an alfred command.



Have other awesome Focus integrations? Let us know at @heyfocusapp or support@heyfocus.com


Download Focus and steal back your productivity. Get more work done, stay in the flow and create your perfect work environment with 1-click.

Stay up to date with the latest Focus updates and news