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?


start_hdmi() {

run_hdmi() {
    DISPLAY=:8 LD_LIBRARY_PATH=/usr/lib/nvidia-current:$LD_LIBRARY_PATH optirun "$@"

if [[ "$@" == "start" ]]; then
elif [[ "$#" == "2" && "$1" == "run" ]]; then
    run_hdmi "$2"
    echo "$0 start|run <program>"
  • This is not Ubuntu specific. – con-f-use Aug 25 '12 at 15:19
  • @con-f-use bash scripting 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. – Eliah Kagan Aug 25 '12 at 18:28

Remove the double quotes here run_hdmi "$2"

  • cool, that was easy :) Is it also possibe to not use quotes when running the script? – Matt Aug 25 '12 at 14:37
  • Obviously, no. Because the script will take only the name of a program then. – seeline Aug 25 '12 at 14:48
  • For sure, but with further modifications of the script it would be possible, wouldn't it? – Matt Aug 25 '12 at 14:49
  • May be.) Modify. – seeline Aug 25 '12 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.