Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

stefaniecg

macrumors newbie
Original poster
Feb 15, 2023
2
1
I'd like to create an automation of my focus mode based on a calendar event text in it's topic.

Let's say from 9h to 12h i created an event in my calendar called "Labor in project x".
I'd like that automatically my focus mode is set to "Work" at 9h until 12h by recognizing in my event the word: "Labor" in the text of the topic.

Does any one know how to do this?

Focus modes can be automated via normal configuration [1] but not based on the text of the topic of an event in my calendar.
Hope someone can help !
Thanx

Ref.
[1] https://www.macrumors.com/how-to/schedule-focus-modes/
 
  • Like
Reactions: MareLuce
Well, nothing straightforward.

Guessing here, have not done myself.

Since posted in Ventura sub-forum, can create an Automator script that is a simple one liner. Open Automator, select "Calendar Alarm". Add "Run Shell Script" action and give it a value of:

Code:
/usr/bin/shortcuts run "name of do focus shortcut here"

Save.

You will now have an Automator calendar on the Mac, but it's only on that Mac iirc. Can add events to that calendar in Calendar that when trigger will run your Automation.

"name of do focus shortcut here" would be a Shortcut that looks at the Calendar to find the event and determine what to do, if anything. In this case "Set Focus" action.

iOS has some other hacks, for example, Automations for "when email arrives" or "when Message arrives", that can trigger a Shortcut to run to set a Focus, and if sharing Focus status across devices, will trigger the Mac to go to that Focus as well. But problem is that need to create an event in Mac's Calendar to send an email as an alert vs iOS Calendar does not have that option.
 
updated:
I (apparently falsely) assumed Shortcuts.app offers the same features on Ventura as on iOS/iPadOS (no current way to test).
I'll leave a possible workaround for iOS/iPadOS here anyway.
As mentioned by @NoBoMac, the problematic part is dealing with the timeout. So the following expects one does not actively need the "Low Power Mode" as it gets misused by the shortcut to re-trigger itself.
Prerequisites:
- The Shortcut gets initially triggered once by a fixed time at (08:00 AM), daily and runs for ~1 minute​
- The second trigger is Low Power Mode gets turned Off which the shortcut executes at the end of the run to re-trigger itself and results in a ~1 minute execution interval loop (Low Power Mode only stays active for <1 second)​
The Shortcut itself:
Part 1: Ensures only one instance of the shortcut is running at the same time​
Part 2: Checks if it runs during business hours (08:00 AM - 05:00 PM), otherwise the loop is stopped​
Part 3 (main):​
- If the current event of the calendar Work contains "Labor", the focus Work gets activated (if not already active)​
- If "Labor" is not found, the focus Work gets deactivated​

If you want it changed (longer interval) or a link, PM me. It could probably be improved vastly but I'm new to Shortcuts.
 

Attachments

  • Set.Focus.based.on.Calendar.Entry_1.png
    Set.Focus.based.on.Calendar.Entry_1.png
    211.5 KB · Views: 532
  • Set.Focus.based.on.Calendar.Entry_2.png
    Set.Focus.based.on.Calendar.Entry_2.png
    100 KB · Views: 532
  • Set.Focus.based.on.Calendar.Entry_3.png
    Set.Focus.based.on.Calendar.Entry_3.png
    151 KB · Views: 533
Last edited:
Unfortunately, that Shortcut will probably quit after a while due to running too long. Apple has baked in a timeout value to prevent running down the battery with an infinite loop type situation.

For example, this was brought up in this thread and member ran into the timeout problem.
 
  • Like
Reactions: arw
Good to know.
Will test it throughout tomorrow and correct my post accordingly.
So it's probably better to keep the duration shorter but trigger it
a) fixed times multiple times per day
b) by using open/close any application

Updated previous post with a possible Shortcuts.app workaround.
 
Last edited:
Either or. However, looks like OP is wanting a Mac solution and the Automation options on iOS are not there for Mac.

Can simulate fixed time Automation via a launchagent on the Mac: every minute launch shortcuts command line app to run a Shortcut to check for a Calendar event.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.