Running shortcuts on Mac OS
-
Hi there.
I'm trying to see if I can run a Mac OS shortcut using TriggerCMD with a voice command via Alexa.
So far I have not managed to get this working properly and need some help.
I have created a command using the GUI editor and I have used the command: shortcuts run agency
(agency is the name of my shortcut which opens two apps)
If I run the command directly from the GUI command editor, the shortcut doesn't run until I close the GUI and then open it again? This seems strange as this does not happen with the sample Calculator command?
I have tried using the same command (shortcuts run agency) in Mac OS Terminal and it works immediately.
What am I doing wrong?
Thanks in advance.
-
@admreece, you'll have to get me started. I'm unfamiliar with this shortcuts command.
I found this app, but it's only for iOS devices.
https://apps.apple.com/app/shortcuts/id915249334How do I get that shortcuts command on my mac?
-
@russ hey there, thanks for responding.
I'm sure you know that to get shortcuts on your mac you need to be running MacOS Monterey.
Because I read that TriggerCMD commands use the same format as what can run from the command line, I did a Google search for how to run shortcuts from the command line and the following is what I found: https://sixcolors.com/post/2021/12/run-shortcuts-from-the-mac-command-line/
As I previously mentioned, if you type: shortcuts run followed by the name of your shortcut, the Mac will run that shortcut.
In my case this would be: shortcuts run agency
(agency being the name of my shortcut).
-
@admreece, I didn't know I needed Monterey to run shortcuts, but I do now thanks to you.
For some reason my mac won't let me upgrade to Monterey, so now I have a nice excuse to shop for a new mac.
In the meantime, I suggest running this command to find the full path to the shortcuts command:
which shortcuts
Then use that full path in your TRIGGERcmd command like this (assuming the folder is /usr/bin):
/usr/bin/shortcuts agency
If that doesn't work, you could try making a agency.scpt apple script like that link suggested:
tell application "Shortcuts Events" set theResult to run shortcut "agency" end tell
You could run that script with a command like this:
/usr/bin/osascript ~/agency.scpt
-
@russ Many thanks, I've just tried using the full path option and the same thing happens as before, the command only works when I quit out of the HUI and then open it again. I will try the Apple Script option next.
-
@russ OK, I've got this to work thanks to your help.
I created an AppleScript as described and added the path into the GUI command field.
Now I can ask Alexa to run shortcuts and it works perfectly!!
Now another challenge. Can I somehow run the TriggerCMD command using an Alexa Routine, rather than using my voice command?
So for example I already have a routine that runs when I say "Alexa good morning" that turns on my office light, turns on my radiator and reads out my calendar for the day. I'd like to add the TriggerCMD command to this routine. Is that possible?
-
@admreece, definately. A lot of TRIGGERcmd users use routines to run their commands.
In your Alexa Routine under "When this happens" select "Smart Home" then pick your command.
This video shows some screenshots. It also shows how you can run a routine when you run one of your commands.
-
@russ many thanks, I’ll take a look.
-