Apple Scripts to Shell Scripts to Python?

Posted on
Thu Jul 02, 2020 11:22 am
jltnol offline
Posts: 493
Joined: Oct 15, 2013

Apple Scripts to Shell Scripts to Python?

So I've successfully migrated my desktop iMac which has my iTunes... I mean Music library, and a few days later, did the same for the Indigo Server. Both are running on Catalina now, and while initially I had some doubts and concerns, the current built-in iTunes plug in has been working absolutely perfectly. I really haven't had any issues to speak of, so I hope that bodes well for this plugin going forward.

I did have a few things connected to the "local iTunes plugin", which doesn't work in Catalina. The good news is I've managed to cobble together a few AppleScripts for Music to do what I need... and then have Indigo run a shell script that runs the apple script. Although a bit "clumsy", this works fine. Then found out that I could invoke an AppleScript directly in the shell script, which meant one less step to get things done. With my tiny toolkit that know and understand, I can easily see my way to accomplish everything I think I'll need in replacing some of the local iTunes plugin functions. it may not be pretty, but is simple, and easy for me to understand and adjust as necessary.

The only issue is those shell scripts all reside on the Indigo Server, which doesn't have a monitor attached, so I have to VNC into the server to make any changes and adjustments. Not a big deal really, but requires one step I wish I didn't have to take. So I'm wondering if it's possible to convert these small scripts to embedded Python scripts, so I can more easily edit them from the Indigo Client on my desktop. I have a handful of scripts like this but getting just this one converted, if possible, will guide me thru to success with the others.

Here is the original Apple Script
Code: Select all
tell application "Music"
   play playlist named "LinnClassical"
   tell application "Music" to set selected of AirPlay device "Denon AVR-X4000" to true
   delay 10.0
   tell application "Music" to set sound volume of AirPlay device "Denon AVR-X4000" to 25
end tell


And although not exactly the same, here is the shell script:

Code: Select all
#!/bin/zsh

osascript -e 'tell application "Music" to play playlist "LinnClassical"'
osascript -e 'tell application "Music" to set selected of AirPlay device "Denon AVR-X4000" to true'
osascript -e 'tell application "Music" to set the sound volume to 40'
sleep 10
osascript -e 'tell application "Music" to set sound volume of AirPlay device "Denon AVR-X4000" to 25'

Posted on
Thu Jul 02, 2020 12:47 pm
FlyingDiver online
User avatar
Posts: 4308
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Apple Scripts to Shell Scripts to Python?

Or you could enable File Sharing on the Indigo system and share the Indigo directory (or wherever you store the scripts), and then just edit them directly on your personal Mac.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Jul 02, 2020 1:38 pm
jay (support) offline
Site Admin
User avatar
Posts: 16306
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Apple Scripts to Shell Scripts to Python?

Indigo will still execute AppleScripts directly using the Execute Script action pointing to an AppleScript file (not embedded), no need to run them in a shell. Nothing that references the IndigoServer process of course, but all else should work fine. Certainly the AppleScript above should work with without issue.

FlyingDiver wrote:
Or you could enable File Sharing on the Indigo system and share the Indigo directory (or wherever you store the scripts), and then just edit them directly on your personal Mac.


+1 - this is definitely my preferred approach.

FYI - we're making some changes in the next Indigo release (not sure when yet) that will improve a plugin's ability to run AppleScripts that talk to other apps (the permission stuff in Catalina often gets in the way at the moment). This should make patching the iTunes Local Control plugin possible and have it work correctly in Catalina.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jul 02, 2020 3:18 pm
jltnol offline
Posts: 493
Joined: Oct 15, 2013

Re: Apple Scripts to Shell Scripts to Python?

I've tried the file sharing approach, but just prefer the VNC method... easier for me to keep the clutter down. :)

Thanks again for your very helpful suggestions.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests