Is There a Way to Use a macOS Focus Mode Change as a Trigger for Keyboard Maestro?

That would be awesome to use this feature (that can be automated via iOS) as a trigger for changing setup Macros.

Can you not use a Shortcut, triggered when you enter a certain Focus mode, to run one or more KM macros using kmtrigger URLs?

1 Like

AFAIK you can use a Focus Mode change as a trigger in Shortcuts for iOS/iPadOS, but not on macOS.

Shortcuts on macOS is missing the “Automation” tab that we have in the mobile counterparts.

Or am I missing something?

Only the fact that I'm an idiot :wink: Not being a Focus Mode or Shortcuts user but having heard the last Automators podcast about Focus Mode, I confused iOS and macOS functionality.

(Seriously Apple -- how are Focus Mode Shortcut triggers not a thing on macOS yet? Ventura, maybe?)

How are you setting Focus Mode? While we wait on Apple you could do things in reverse -- use KM to trigger the setup macros and for switching Focus.

Currently, I can trigger a Focus Mode from a Macro via Shortcuts, just like Brett Terpstra showed here.

There's also a script that can fetch the current Focus Mode (took it from Automators Discourse) and I've set it to save the focus mode to a variable whenever I wake my laptop. However it will not update manually if I happen to change the Focus Mode after I wake my computer.

That's fine and all, but I still have to find a way to use other triggers to allow for a KBM macro to run the setup and then set the desired Focus Mode.

Given that Focus Mode has a bunch of triggers built into every device I use (including the watch) and that this status sync to all of them, I figured it would be nice to have my Mac trigger a different setup macro (specific apps and settings) for each one of these Focus Modes.

At this moment, I tend to use local networks as a proxy to location, but that misses the point since sometimes I do work out of my office.

Having to manually trigger the Focus Mode is, of course a minor annoyance, but still an annoyance nevertheless.

Given that, look some of Rosemary Orchard's other posts -- in the Automator episode I mentioned she talked about syncing her Mac to her iOS devices via DataJar and/or Pushcut. So you could change Focus Mode on your phone and have your Mac react to that, with it also running macros etc.

You could also look at using the Focus switch on the iOS device to send a KM "Remote Trigger" to your Mac, kicking off a macro that does the things and sets Focus mode for you that way.

I saw the script you refer to when I looked earlier, but it's set me thinking... If there's something you can check to find the current Focus Mode, presumably there's something that's changed when you change Focus Modes... If it's a file, that raises the possibility of a LaunchAgent using WatchPaths and triggering a response whenever that/those somethings change -- (a lot less resource intensive than the simple fix of your current Focus Mode checker once every second!).

Stuff to think about -- but, given the work involved, you might want to start by checking the beta test reports and seeing if Ventura brings what you want natively!