I wrote the bash script below (called hdmi_output) and it's working in most parts as I expect it.
For example, I run hdmi_output run firefox and Firefox is started on the external monitor.
But sometimes I want to run programs with arguments and this doesn't work anymore. E.g. when running hdmi_output run "firefox -P -no-remote", I get this:
/usr/bin/vglrun: 296: exec: **firefox -P -no-remote: not found
I wrote it in quotes to be treated as one variable, but it doesn't seem to work.
Can anyone help me to improve the script, maybe shift command should be used?
#!/bin/bash
start_hdmi() {
...
...
}
run_hdmi() {
DISPLAY=:8 LD_LIBRARY_PATH=/usr/lib/nvidia-current:$LD_LIBRARY_PATH optirun "$@"
}
if [[ "$@" == "start" ]]; then
start_hdmi
elif [[ "$#" == "2" && "$1" == "run" ]]; then
run_hdmi "$2"
else
echo "$0 start|run <program>"
fi
bashscripting questions are almost always considered on topic here; I see no reason why this should be one of the very rare exceptions. Furthermore, some details here vary from one Unix-like OS to another, making this even more clearly on-topic for our site.