Six Colors
Six Colors

This Week's Sponsor

Magic Lasso Adblock: YouTube ad blocker for Safari


Help a Mac automation find Focus

I’m intrigued by the new Focus modes in macOS Monterey and iOS 15, but frustrated by the fact that there’s no easy way for an automation tool to detect the current Focus status.

Except! There is. If you know where to look. After lamenting this situation in the Automators Forum, Drew Kerr swept in with a solution—namely a JavaScript for Mac Automation script that parses the contents of the Do Not Disturb database in ~/Library/DoNotDisturb and returns the name of the current Focus mode, or “No focus” if there’s no current focus.

You can save this as a script in Script Editor, or as a .jxa text file that you can run from the command line:

osascript -l JavaScript ./whichfocus.jxa

Or you can do what I did, and pour it into Shortcuts’ Run JavaScript for Automation action. There are many options.

I love this. Thanks to Drew for figuring it out… and say, Apple, don’t you think “get current Focus mode” should just be an action in a future version of Shortcuts?

—Linked by Jason Snell

Search Six Colors