The Escape Hatch

My last post was about the limitations of Siri Shortcuts. I used rating songs as an example of a simple automation that isn’t supported on iOS, but that is easily accomplished on the Mac in various ways. One of those ways was using Automator. Automator is a lot like Shortcuts in that both have drag-and-drop actions that can be visually combined to make workflows. The fact is that I find myself almost as frustrated with Automator as I do with Siri Shortcuts for the same reason that actions inherently limit automation only to what developers anticipate and prioritize. Sure I was able to rate music using Automator, but the existence of “Set Options of Music Songs”1 is more a sign of what Apple thought was important in the mid-2000s than anything else. In fact, I would argue any action found in Automator could easily have a Siri Shortcut equivalent… almost. There is one kind of action that only Automator can perform, and that’s running automation scripts. Automator offers the following three actions:

  • Run AppleScript
  • Run JavaScript
  • Run Shell Script

These “Run *Script” commands are an escape hatch for when I inevitably find something that isn’t supported by the prebuilt actions available2. Truth be told, this actually happened when I was creating the examples for my last post. I had originally intended to include showing a notification with song details in my examples, but like Siri Shortcuts has no action to “Set Details of Music”, Automator has no action to “Get Details of Music”. Here’s an updated example using “Run AppleScript” to get the details of a song and create the notification text:

Updated Automator Example

As far as I can tell, Siri Shortcuts has no means to run automation scripts. Its “Run Script” action seems to be a Python editor and runtime, which while very cool, is not really automation. While Shortcuts has no equivalent to “Run AppleScript”, it does have an escape hatch of sorts. “Run Script Over SSH” makes it possible to hand off automation from Siri Shortcuts to a Mac via secure shell (SSH). Having access to a shell alone opens up a world of possibilities, and on a Mac it also means having access to AppleScript via the osascript executable. In other words, you can still run automation scripts using Shortcuts, just not on iOS.

Here’s my current solution to rate the currently playing song using Siri Shortcuts, SSH, and AppleScript.

First, I have a shortcut for each star rating. Each of these shortcuts…

  1. Sets a numeric rating
  2. Passes that numeric rating to another shortcut named “Rate over SSH”

This is what “Rate ★★★★★” looks like:

Rate 5 Stars

My “Rate Over SSH”3 shortcut then…

  1. Takes in the numeric rating provided from the previous shortcut
  2. Gets the current song
  3. Gets the artist, album, and name of that song
  4. Combines the above along with the numeric rating as text
  5. Passes the combined text as arguments to an SSH command sent to my Mac

Here’s what it looks like:

Rate over SSH

On my Mac, the SSH command runs the below AppleScript.

on run {artistName, albumName, songName, newRating}
    tell application "Music"
        repeat with matchingTrack in (every track whose name is songName and album is albumName and artist is artistName)
            set the rating of matchingTrack to newRating * 1

            set {updatedArtist, updatedAlbum, updatedSong, updatedRating} to the {artist, album, name, rating} of matchingTrack

            set singleDigitRating to updatedRating / 20
            set starRating to ""
            repeat singleDigitRating times
                set starRating to starRating & "★"
            end repeat

            set response to "Rated " & updatedSong & " from " & updatedAlbum & " by " & updatedArtist & " to " & starRating

            display notification quoted form of response with title "Rated Song"
            do shell script "echo " & quoted form of response
        end repeat
    end tell
end run

This AppleScript…

  1. Tells Music to get every track whose artist, album, and name all match the provided criteria4 and with each of those tracks…
    1. Sets the new star rating
    2. Determines the star(s) equivalent from the updated rating
    3. Builds a response using the updated song
    4. Displays that response as a notification on my Mac
    5. Returns that response to the secure shell being used by “Run script over SSH” in Siri Shortcuts

Once “Run script over SSH” completes, the returned response is then used to also show a notification in iOS.

Rated Song Notification

“Run script over SSH” is an escape hatch, but one that is as much delightful as it is a reminder of the limitations of Shortcuts when compared to AppleScript. That may sound unfair given how much people really do accomplish with Shortcuts, but I don’t see how anyone could argue otherwise. Some like to say that the iPad is the only computer they really need. While I suspect that’s true for a lot of people, those who love automation can’t say the same for Siri Shortcuts so long as it’s only escape hatch is the Mac.


  1. It’s almost as if Apple merely found all occurrences of “iTunes” and replaced them with “Music”. 
  2. By some measure, running scripts only when needed is better than scripting alone in that they can be used alongside other prebuilt actions the don’t require any coding. 
  3. The name “Rate Over SSH” is somewhat of a misnomer in that this shortcut also performs the logic of getting music details. Moving the heavy lifting to this one shortcut keeps duplicating actions to a minimum. 
  4. Because Siri Shortcuts doesn’t expose any unique identifier as a detail of music, I have find to the song in Music on my Mac. While not ideal, I haven’t run into issues thus far. It’s also worth noting that I have opted to rate every track with matching artist, album, and name rather than conservatively rate just the first track. My thinking is that multiple matching songs would very likely share the same rating because they are either duplicates that should be deleted or different recordings that should further be organized through some other means.