#!/bin/bash run_qml() { local script=$1 dir=$2 shift 2 case $dir in /*) ;; *) dir=./$dir esac # One may complain about JSON, but figuring out how QML parses non-JSON # argument strings is likely to be an exercise in pain by comparison. kid3-cli -c "$( printf '%s\0' "$script" "$@" | jq -Rsc '{ method: "execute", params: (["@qml"] + (split("\u0000")[:-1])) }' )" "$dir" } # /dir appears to prime the script for methods such as app.firstFile(), # app.nextFile(), app.getFrame(), app.setFrame() and such. To access # optional_args, use getArguments(). run_qml /path/to/qml /dir # optional_args...