Creating a timer shortcut in MacOS Monterey

MacOS Shortcuts, AppleScript and the Menubar Countdown app

Apple Shortcut and Menubar Countdown logos I recently upgraded to MacOS Monterey. It’s ok. The most exciting thing is that MacOS now supports Shortcuts. A Redditor in r/shortcuts asked if there was a way to set a timer with Shortcuts on a Mac. This started my quest to figure it out.

Finding the right app

By default, if you ask Siri to start a timer on a Mac, it’ll create a reminder instead. There’s no built in timer app on MacOS, so the first step was to find a Mac app with shortcut integration. I searched for awhile and couldn’t find any Mac timer apps that mentioned Shortcuts.

Since I have an M1 Mac, I looked for iPad and iPhone timer apps next. There are plenty that allowed Shortcuts to start or stop existing timers, but none of them allowed Shortcuts to create a new timer based on an provided variable. I came to the conclusion there wasn’t a Mac timer app that integrated with Shortcuts.

AppleScript my old friend

I pivoted a bit and started searching for apps that could be controlled via the command line or AppleScript. This led me to Menubar Countdown. Like the name implies, it’s a Mac app that places a countdown in your menu bar. It supports Monterey and it can be controlled by AppleScript. For example:

1
2
3
4
5
6
tell application "Menubar Countdown"
    set hours to 0
	set minutes to 10
	set seconds to 0
	start timer
end tell

Shortcuts on MacOS supports AppleScript so it’s able to control the Menubar Countdown app. I created a quick shortcut that asked for a number of minutes and then ran the AppleScript that would start the timer. It worked beautifully… until I used 60 or more minutes.

Shortcut logic

The Menubar Countdown app doesn’t allow more than 59 minutes in the minute field (you’re expected to use the hour field). If the AppleScript tries to send 60 or more to the minute field, the value is rejected and the timer just runs with the previous time set.

Luckily, I’d seen a way to convert minutes to hours and minutes in Shortcuts. I can’t find the original source, but I’ll update this post if I find it. Basically, the shortcut sets the time to midnight (00:00) and then adds the minutes the user inputs. It then outputs hours and minutes as separate values. For instance, if you add 140 minutes to midnight, you get 2:20 AM. Taking the hours and the minutes you get 2 hours and 20 minutes and then both of those can be passed to a list which is then passed to the AppleScript. Mac Timer Logic

Finally, there was some weirdness with this logic if it was less than 60 minutes. The previously entered hours wouldn’t be zeroed out. I added an if statement to only pass the minutes if it’s under 60, and to do the whole calculation if it’s 60 or more.

Where to get it

If you’d like to download the completed shortcut, you can find it on Routine Hub. Get the Menubar Countdown shortcut FYI, RoutineHub doesn’t show Mac as on OS option yet, so the metadata is a little weird.

Universal Timer App

One more thing I wanted was to have a single shortcut that would work either on my phone or my Mac. Using Device Model it’s possible to identify the device running the shortcut as iPhone, Mac, iPad, etc. I created a small shortcut with an if statement that would run my Menubar Countdown shortcut on my Mac, or run my Quick Timer Plus shortcut on other devices. universal timer shortcut Download a sample Universal Timer shortcut

Something to look forward to

While my shortcut works, it’s a little complicated. An app to look forward to is Just Timers. I’ve been beta testing version 2.0 that supports Shortcuts. Shortcuts is able to create new timers and (in theory) start the timer. The one bug I found is that Shortcuts can’t actually start the timer. Once the Just Timers dev irons out the bugs, it might be the best option for a universal timer app. Just Timers 2.0 will support iPad, iPhone and MacOS.

Downloads

If you skipped to the end of this post to download the app and shortcut, here you go: Menubar Countdown on GitHub
Menubar Countdown shortcut on RoutineHub


See also