hassio-addons
hassio-addons copied to clipboard
Mopidy: Suggestion: Quote options[] to support extended parameters
Hi,
tried to reroute the local audio output to a different sound card on the raspberry pi. In principle, the gstreamer configuration for mopidy.conf is quite clear:
[audio]
output = alsasink device=hw:2,0
Or, for the command line of mopidy:
mopidy -o audio/output='alsasink device=hw:2,0'
Unfortunately, run.sh does not quote the "value" of "options" parameters, so a configuration like
{
"name": "audio/output",
"value": "alsasink device=hw:2,0"
},
ends up as an invalid extra parameter "device" on mopidy's command line, which crashes the mopidy call:
mopidy -o audio/output=alsasink device=hw:2,0
^^^^^^^^
Is it possible to add some simple quoting to run.sh? Alternatively, include a mopdiy.conf that can be edited by the user (from /share/, for example).
Apart from that: Great work!
You could write your config as
{
"name": "audio/output",
"value": "\"alsasink device=hw:2,0\""
}
It should work.
Hi I am trying to exactly the same thing and the first think that came in my mind is to double escape the string as @bestlibre suggested. Unfortunately this does not yield the desired results as in the next command the parameters are passed in a variable and wordsplitting is performed without taking into account the escapes.
usage: mopidy [-h] [--version] [-q] [-v] [--save-debug-log] [--config FILES]
[-o OPTIONS]
unrecognized command: device=hw:1,0'
See BashFAQ050 for more details on the problem.
Possible solution
Use eval
when running modipy this will trigger syntactical parsing before executing the command eval mopidy --config $config $options
. There is a security risk here that if someone has control over the options could run any kind of code inside the docker. But I feel like changing the options of the addon has already enough control.
Now it is possible to set sound card in plugin settings