Another Time/Date Trigger Question

Hello Friends

I need a little help please.

I’d like to create a shortcut that is triggered depending on what time of day it is.

For simplicity, let’s say that I want an outcome to be 2 possibilities based on the time of day:

IF: it is before 10am >>> THEN: Run X
ELSE: Run Y

Is this possible?

TIA, Tony

That reads like two different requests.

If you want a time-based trigger, then you specify a shortcut top run at a particular time using Shortcuts’ personal automations (i*OS).

If you want to trigger a shortcut in a non-time-based way (NFC tag tap, manual run, geo-fence, etc.) and then decide what to do based on the time, you would do it exactly as you have described.

Here’s an example of one way you could do this.

Hope that helps.

2 Likes

I am a little unclear on exactly what you want. If you are triggering a Shortcut and then want different outcomes depending upon the before/after 10 o’clock, the following will accomplish that:

Shortcut: Before and After 10am

…formatting the date as:

Hope this helps

EDIT:
Beaten by 1m in answering! Slightly different Shortcut so I’ll leave mine up too.

1 Like

In case it is useful, you can shrink the shortcut a little by using a text action rather than the combo of a date and number.

The text can become show results and drop the final one as the final action is common and driven by a single step. But, beyond an example, not necessarily useful if what you want to do with the result could change.

Because it is a numeric check the additional “H” in the date formatting I believe is redundant. A single “H” should still output 0-23, the “HH” would format with a leading zero for single-digit hours.

None of these change the functionality it provides, I think it just condenses and simplifies it a little … though shorter of course isn’t always simpler :man_shrugging:t2: :laughing:

Cheers.

That’s just a habit I’ve tended to use: put the text in a (magic) variable and then use the variable as a building block for longer text or in the output itself. I just prefer it to potentially having a long string in a Show Result field and have tended to use it in all cases for consistency in style. I also quite like the Show Result after the If as, at a glance through the Shortcut with the If collapsed, I can see that the If is creating a text result that the Show Result is displaying. With the Show Result inside the If, collapsing the If hides everything.

I can’t find Personal Automations on macOS Shortcuts.

I ended up using launchd to trigger my macOS Shortcut using Lingon to create the.plist file.

Is there another, better way to trigger a Shortcut on macOS?

It isn’t available on macOS. You would have to ask apple why.

Lingon and plists are fine. You could also use other schedules (such as that built into Keyboard Maestro), or a dedicated app like Shorter. But in terms of one being better than another, there’s probably a heavy dose of personal preference in there.

I just made a Feature Request at:

My message was:

Shortcuts on iOS have “Personal Automations,” 
which allow Shortcuts to be triggered at a particular 
time; Shortcuts on macOS does not.

Please add Personal Automations to macOS Shortcuts.

Perhaps others would also give Apple similar feedback.

Thanks for all the helpful responses. This is a great group.

I think I need to be a more specific on what I’m trying to accomplish. I’ll also admit that it’s probably a little “far out,” but here goes.

I thought it would be cool that when I approached my iMac, it ran a shortcut that based on the time of day would give me a different result (If/Then)

If its before 12pm
Run “X”
Else
Run “Y”

Example
At 7am, I walk up to my iMac Pro, triggering a shortcut that based on the time of day (in this case, 7am),

  1. Reads a text: “Good Morning Anthony. Let’s start your day.”
  2. Opens my “Morning Planning Workflow” Shortcut (Opens email, Calendar, Omnifocus, whatever)

but At 3pm (or anytime after Morning), I walk up to my iMac, but this time

  1. Reads a text field: " Good Afternoon, Anthony…"
  2. Opens my “Afternoon Workflow.”

That’s actually quite different in terms of triggers! “Approaching” is a rather unusual request, but I think something viable is possible.

Keyboard Maestro is usually my goto option for triggers, but there is another app that ofers some other triggers that may be of use for you, and that’s EventScripts.

I would hope that you have security enabled to lock your Mac when you are away from it. That being the case, an unlock trigger might be a good option.

If you don’t have that (and really you should), maybe you could use the movement trigger that uses your webcam to watch for movement to get a true “approaching” trigger?

The conditional logic (the if/else), can go in your Shortcut as already outlined, and you can trigger shortcuts from a script.

You’ll need to lay out a bit of cash to facilitate the trigger using this approach, but only a couple of fancy coffee’s worth.

Hope that helps.