Trigger a command with a Shortcut via Siri
-
You can run commands on your computers with Siri using a Shortcut. Here's how:
-
Download the Shortcuts app on your iOS device.
-
Open this link or scan this QR code from your iOS device:
-
Fill in the computer, trigger, and token fields. The params field is optional.
-
In the shortcut's settings, tap "Add to Siri" and record your personal phrase.
Here's a Youtube video showing how it works:
https://youtu.be/YBOiWBokal8 -
-
R Russ referenced this topic on
-
R Russ pinned this topic on
-
hi -- how can this be used to display or say the result?
here's a command that works on alexa:
osascript -e 'tell application "Music" to set result to "This song is " & name of current track & " by " & artist of current track & " on the " & year of current track & " album " & album of current track' | sed 's/^/"/;s/$/"/' | xargs -I{} ~/.TRIGGERcmdData/sendresult.sh {}
when created with the QR code, the last step is "Get contents of TEXT". result: nothing. I added "Show result <contents of URL>" (defaults to that parameter). result: "no authorization header was found".
-
@gajahduduk said in Trigger a command with a Shortcut via Siri:
osascript -e 'tell application "Music" to set result to "This song is " & name of current track & " by " & artist of current track & " on the " & year of current track & " album " & album of current track' | sed 's/^/"/;s/$/"/' | xargs -I{} ~/.TRIGGERcmdData/sendresult.sh {}
Can you help me get started? I tried your command it doesn't seem to work. Is there something I need to do in the Music app first?
russ@macbook-air ~ % osascript -e 'tell application "Music" to set result to "This song is " & name of current track & " by " & artist of current track & " on the " & year of current track & " album " & album of current track' 60:64: execution error: Can’t make name of «class pTrk» of application "Music" into type Unicode text. (-1700)
-
@Russ i think your Music app's player state is stopped. play a track, or play one and pause it, and it should work. (mine is never stopped :).
to test the basic functionality leave out the last pipe part (" | xargs" …), and run the rest in Terminal.
osascript -e 'tell application "Music" to set result to "This song is " & name of current track & " by " & artist of current track & " on the " & year of current track & " album " & album of current track' | sed 's/^/"/;s/$/"/'
as noted, this works for the "original" Alexa. Since I've been having problems with Alexa Plus and TriggerCMD, I was trying the Shortcuts route.