Shortcuts
Shortcuts and AppleScript on the Mac
Dr. Drang has posted some thoughts and questions about the future of automation on the Mac.
Shortcuts and SSHing to Snow Leopard
Like you-wouldn't-believe-how-many other people, I still run an old Mac Mini with Snow Leopard on it. It's been pretty reliable as an occasional music server and we still use it to play iTunes internet radio on AirPlay devices around the house. It also manages some backup tasks on my network. It runs headless and I access it through Screen Sharing when necessary.
It is more difficult then it used to be to remotely control Snow Leopard with AppleScript from newer operating systems. At one time, you could just address the machine and run commands with a username and password. Now you need to set up SSH. I haven't done that and just use Screen Sharing.
But, believe it or not, the Run Script Over SSH action I described earlier works with Snow Leopard out-of-the-box. I will now set about creating a batch of Shortcuts to be able to quickly manage stuff on the Mac Mini with AppleScript, like playing a parrticular radio station in iTunes, shutting music down, changing AirPlay devices and so on, which I can call from my iPhone. Pretty cool.
Scripting to a Mac with iOS Shortcuts
I'm not particularly bowled over by Shortcuts on iOS. I just don't use my iPhone and iPads rigorously enough that I'm inspired to automate many tasks. But I get that it's a thing.
What I find very interesting however is that you can use Shortcuts to launch AppleScripts on a targeted Mac. So, while the "Music" actions on iOS are somewhat limited, there's actually some potential usefulness in calling scripts (via Siri, even) from your iOS device to control iTunes on a Mac.
A nice basic tutorial by the great folks at Late Night Software explains how set this up. Essentially, you use the Run Script over SSH action to enter an osascript command to launch a script on a specified Mac. If you've ever done anything with launchd then you will recognize some similarities.
There are some limitations. First, AppleScript does not run on iOS. So anything you want to do with this technique will necessarily be on one particular Mac. (While I can imagine that it is possible to run other SSH commands from that Mac to other Macs, making all of that swing is beyond the scope of this article.)
Second, I am working strictly with scripting iTunes on a Mac. Many other apps on your Mac can be controlled with AppleScript, too.
Third, there is limited opportunity for user-interaction and feedback. (Depending on the use case, it is possible to manage some simple back-and-forth user-interaction in Shortcuts. But, again: beyond, scope, article.)
So, considering those parameters, there aren't many iTunes track and playlist management things I'd want to do remotely; I'd prefer to be operating on track info while sitting in front of iTunes. But we can still use Shortcuts to perform some serviceable tasks with iTunes remotely, things that can't be done conveniently with the Remote app on iOS.
Below, I describe how to create some Shortcuts that can launch scripts on your Mac. One will save the currently playing track to a "Favorites" playlist, another to change the AirPlay configuration and, lastly, one that pauses iTunes for five minutes. These may give you ideas for your own Shortcuts.