Launch an external application with LUA

In the scripting section of the Ardour manual (The Ardour Manual - Lua Scripting), it says you can “launch an external application when a track is soloed” What is the best way to launch an external application?

For example I am trying to launch musescore to automatically open an exported midi file, if I do os.execute(mscore) it just crashes Ardour. I did find I was able to run “ls -l” and view the output.

What is the best way to launch a GUI app with LUA or is that not really possible?

1 Like

Oh I didn’t know about this functionality, it would be great if I could select a region and have it bounced and opened in Audacity…

perhaps you’re missing quotes? or have you set mscore variable to the absolute path?

Also I assume you don’t want Ardour’s UI thread to stall until you close the child app, but want to fork a process. Assuming you’re on Linux or macOS try:

os.forkexec ("/bin/sh", "-c", "mscore")

See also

Thank you for your help on this Robin. To clarify I forgot to put the quotes in when I made the post. (Was on my lunch break when I posted).

I tried out the script from the github page and I got xterm to launch, however when I tried to launch musescore, I see that it spawns the process but GUI never launches.

I have tried both with the same result

	os.forkexec ("/usr/bin/mscore")
-- and

os.forkexec ("/bin/sh", "-c", "mscore")

any thoughts?

Perhaps create a small wrapper script and launch that instead to log if there is an error launching mscore. Something like:

exec /usr/bin/mscore 2>&1 >/tmp/debug.mscore

Maybe the issue is that Ardour uses the soundcard… or perhaps some issue with environment (Lua’s forkexec inherits Ardour’s environment, except the LD_LIBRARY_PATH variable).

I got this working:

First create a shell script that starts a cron job that will start musescore with the midi file every minute then have the script pause for 90 seconds then have the script do crontab -r to clear the cronjob so musescore doesn’t keep executing every minute

Something like this:
crontab -l | { cat; echo "*/1 * * * *  DISPLAY=:0.0 /usr/bin/mscore ~/mscore.mid"; } | crontab -

sleep 90

crontab -r

Then in Ardour’s LUA interface call the script


Now all I have to do is use LUA’s file functions to automatically create the script and find a way to pass in the name of the midi region, awesome!

stay tuned, more to come…