Openbox - multiple commands separated with & for one keypress

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am trying to configure Openbox's rc.xml file in order to manipulate my soundcards with one keypress. Because I have multiple sound cards on my system I have to manipulate multiple sinks at once so I use multiple commands separated with & like this:



 <keybind key="XF86AudioRaiseVolumen">
<action name="Execute">
<command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5% & pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5% & pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%</command>
</action>
</keybind>


For some reason this won't work in rc.xml. Can anyone help me?










share|improve this question

























    up vote
    0
    down vote

    favorite












    I am trying to configure Openbox's rc.xml file in order to manipulate my soundcards with one keypress. Because I have multiple sound cards on my system I have to manipulate multiple sinks at once so I use multiple commands separated with & like this:



     <keybind key="XF86AudioRaiseVolumen">
    <action name="Execute">
    <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5% & pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5% & pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%</command>
    </action>
    </keybind>


    For some reason this won't work in rc.xml. Can anyone help me?










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to configure Openbox's rc.xml file in order to manipulate my soundcards with one keypress. Because I have multiple sound cards on my system I have to manipulate multiple sinks at once so I use multiple commands separated with & like this:



       <keybind key="XF86AudioRaiseVolumen">
      <action name="Execute">
      <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5% & pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5% & pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%</command>
      </action>
      </keybind>


      For some reason this won't work in rc.xml. Can anyone help me?










      share|improve this question













      I am trying to configure Openbox's rc.xml file in order to manipulate my soundcards with one keypress. Because I have multiple sound cards on my system I have to manipulate multiple sinks at once so I use multiple commands separated with & like this:



       <keybind key="XF86AudioRaiseVolumen">
      <action name="Execute">
      <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5% & pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5% & pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%</command>
      </action>
      </keybind>


      For some reason this won't work in rc.xml. Can anyone help me?







      openbox rc






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 3 '16 at 8:50









      71GA

      43311024




      43311024




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          You need to put the commands into a shell script, make that script executable and then uses this script as the command.



          <command>/usr/local/bin/volume_up</command>


          The contents of /usr/local/bin/volume_up



          #!/bin/sh
          pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5% &
          pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5% &
          pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%


          and make it executable



          chmod +x /usr/local/bin/volume_up


          The reason is that Openbox is not executing the contents of the command element in a shell instead it tries to execute it directly.



          From the documentation for <command>:




          A string which is the command to be executed, along with any arguments
          to be passed to it. The "~" tilde character will be expanded to your
          home directory, but no other shell expansions or scripting syntax may
          be used in the command unless they are passed to the sh command. Also,
          the & character must be written as & in order to be parsed
          correctly. is a deprecated name for .




          Another benefit is that you can rewrite the script to also be able lower the volume



          #!/bin/sh

          change_volume()
          pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output "$1"
          pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo "$1"
          pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 "$1"


          main()
          case "$1" in
          up)
          change_volume +5%
          ;;
          down)
          change_volume -5%
          ;;
          *)
          printf "volume <command>n"
          printf " up n"
          printf " downn"
          esac


          main "$@"


          This would be saved under /usr/local/bin/volume and would be use like this



          <command>/usr/local/bin/volume up</command>
          <command>/usr/local/bin/volume down</command>





          share|improve this answer






















          • This is a possible fix, but not exactly what I need.
            – 71GA
            Sep 21 '16 at 14:10










          • @71GA What is it that you need?
            – Raphael Ahrens
            Sep 21 '16 at 14:41










          • @71GA I added the link to the documentation for <command> and the quote. It mentioned that you can call sh -c to do such a thing.
            – Raphael Ahrens
            Sep 21 '16 at 14:48

















          up vote
          0
          down vote













          If you do not mind the order and the fact that all of these will be executed more or less at once you can do:



          <keybind key="XF86AudioRaiseVolumen">
          <action name="Execute">
          <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5%</command>
          </action>

          <action name="Execute">
          <command>pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5%</command>
          </action>

          <action name="Execute">
          <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%</command>
          </action>
          </keybind>




          share








          New contributor




          Michal Ambroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f307611%2fopenbox-multiple-commands-separated-with-for-one-keypress%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            You need to put the commands into a shell script, make that script executable and then uses this script as the command.



            <command>/usr/local/bin/volume_up</command>


            The contents of /usr/local/bin/volume_up



            #!/bin/sh
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5% &
            pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5% &
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%


            and make it executable



            chmod +x /usr/local/bin/volume_up


            The reason is that Openbox is not executing the contents of the command element in a shell instead it tries to execute it directly.



            From the documentation for <command>:




            A string which is the command to be executed, along with any arguments
            to be passed to it. The "~" tilde character will be expanded to your
            home directory, but no other shell expansions or scripting syntax may
            be used in the command unless they are passed to the sh command. Also,
            the & character must be written as & in order to be parsed
            correctly. is a deprecated name for .




            Another benefit is that you can rewrite the script to also be able lower the volume



            #!/bin/sh

            change_volume()
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output "$1"
            pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo "$1"
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 "$1"


            main()
            case "$1" in
            up)
            change_volume +5%
            ;;
            down)
            change_volume -5%
            ;;
            *)
            printf "volume <command>n"
            printf " up n"
            printf " downn"
            esac


            main "$@"


            This would be saved under /usr/local/bin/volume and would be use like this



            <command>/usr/local/bin/volume up</command>
            <command>/usr/local/bin/volume down</command>





            share|improve this answer






















            • This is a possible fix, but not exactly what I need.
              – 71GA
              Sep 21 '16 at 14:10










            • @71GA What is it that you need?
              – Raphael Ahrens
              Sep 21 '16 at 14:41










            • @71GA I added the link to the documentation for <command> and the quote. It mentioned that you can call sh -c to do such a thing.
              – Raphael Ahrens
              Sep 21 '16 at 14:48














            up vote
            2
            down vote













            You need to put the commands into a shell script, make that script executable and then uses this script as the command.



            <command>/usr/local/bin/volume_up</command>


            The contents of /usr/local/bin/volume_up



            #!/bin/sh
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5% &
            pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5% &
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%


            and make it executable



            chmod +x /usr/local/bin/volume_up


            The reason is that Openbox is not executing the contents of the command element in a shell instead it tries to execute it directly.



            From the documentation for <command>:




            A string which is the command to be executed, along with any arguments
            to be passed to it. The "~" tilde character will be expanded to your
            home directory, but no other shell expansions or scripting syntax may
            be used in the command unless they are passed to the sh command. Also,
            the & character must be written as & in order to be parsed
            correctly. is a deprecated name for .




            Another benefit is that you can rewrite the script to also be able lower the volume



            #!/bin/sh

            change_volume()
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output "$1"
            pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo "$1"
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 "$1"


            main()
            case "$1" in
            up)
            change_volume +5%
            ;;
            down)
            change_volume -5%
            ;;
            *)
            printf "volume <command>n"
            printf " up n"
            printf " downn"
            esac


            main "$@"


            This would be saved under /usr/local/bin/volume and would be use like this



            <command>/usr/local/bin/volume up</command>
            <command>/usr/local/bin/volume down</command>





            share|improve this answer






















            • This is a possible fix, but not exactly what I need.
              – 71GA
              Sep 21 '16 at 14:10










            • @71GA What is it that you need?
              – Raphael Ahrens
              Sep 21 '16 at 14:41










            • @71GA I added the link to the documentation for <command> and the quote. It mentioned that you can call sh -c to do such a thing.
              – Raphael Ahrens
              Sep 21 '16 at 14:48












            up vote
            2
            down vote










            up vote
            2
            down vote









            You need to put the commands into a shell script, make that script executable and then uses this script as the command.



            <command>/usr/local/bin/volume_up</command>


            The contents of /usr/local/bin/volume_up



            #!/bin/sh
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5% &
            pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5% &
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%


            and make it executable



            chmod +x /usr/local/bin/volume_up


            The reason is that Openbox is not executing the contents of the command element in a shell instead it tries to execute it directly.



            From the documentation for <command>:




            A string which is the command to be executed, along with any arguments
            to be passed to it. The "~" tilde character will be expanded to your
            home directory, but no other shell expansions or scripting syntax may
            be used in the command unless they are passed to the sh command. Also,
            the & character must be written as & in order to be parsed
            correctly. is a deprecated name for .




            Another benefit is that you can rewrite the script to also be able lower the volume



            #!/bin/sh

            change_volume()
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output "$1"
            pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo "$1"
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 "$1"


            main()
            case "$1" in
            up)
            change_volume +5%
            ;;
            down)
            change_volume -5%
            ;;
            *)
            printf "volume <command>n"
            printf " up n"
            printf " downn"
            esac


            main "$@"


            This would be saved under /usr/local/bin/volume and would be use like this



            <command>/usr/local/bin/volume up</command>
            <command>/usr/local/bin/volume down</command>





            share|improve this answer














            You need to put the commands into a shell script, make that script executable and then uses this script as the command.



            <command>/usr/local/bin/volume_up</command>


            The contents of /usr/local/bin/volume_up



            #!/bin/sh
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5% &
            pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5% &
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%


            and make it executable



            chmod +x /usr/local/bin/volume_up


            The reason is that Openbox is not executing the contents of the command element in a shell instead it tries to execute it directly.



            From the documentation for <command>:




            A string which is the command to be executed, along with any arguments
            to be passed to it. The "~" tilde character will be expanded to your
            home directory, but no other shell expansions or scripting syntax may
            be used in the command unless they are passed to the sh command. Also,
            the & character must be written as & in order to be parsed
            correctly. is a deprecated name for .




            Another benefit is that you can rewrite the script to also be able lower the volume



            #!/bin/sh

            change_volume()
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output "$1"
            pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo "$1"
            pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 "$1"


            main()
            case "$1" in
            up)
            change_volume +5%
            ;;
            down)
            change_volume -5%
            ;;
            *)
            printf "volume <command>n"
            printf " up n"
            printf " downn"
            esac


            main "$@"


            This would be saved under /usr/local/bin/volume and would be use like this



            <command>/usr/local/bin/volume up</command>
            <command>/usr/local/bin/volume down</command>






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Sep 21 '16 at 14:45

























            answered Sep 20 '16 at 9:42









            Raphael Ahrens

            6,74252845




            6,74252845











            • This is a possible fix, but not exactly what I need.
              – 71GA
              Sep 21 '16 at 14:10










            • @71GA What is it that you need?
              – Raphael Ahrens
              Sep 21 '16 at 14:41










            • @71GA I added the link to the documentation for <command> and the quote. It mentioned that you can call sh -c to do such a thing.
              – Raphael Ahrens
              Sep 21 '16 at 14:48
















            • This is a possible fix, but not exactly what I need.
              – 71GA
              Sep 21 '16 at 14:10










            • @71GA What is it that you need?
              – Raphael Ahrens
              Sep 21 '16 at 14:41










            • @71GA I added the link to the documentation for <command> and the quote. It mentioned that you can call sh -c to do such a thing.
              – Raphael Ahrens
              Sep 21 '16 at 14:48















            This is a possible fix, but not exactly what I need.
            – 71GA
            Sep 21 '16 at 14:10




            This is a possible fix, but not exactly what I need.
            – 71GA
            Sep 21 '16 at 14:10












            @71GA What is it that you need?
            – Raphael Ahrens
            Sep 21 '16 at 14:41




            @71GA What is it that you need?
            – Raphael Ahrens
            Sep 21 '16 at 14:41












            @71GA I added the link to the documentation for <command> and the quote. It mentioned that you can call sh -c to do such a thing.
            – Raphael Ahrens
            Sep 21 '16 at 14:48




            @71GA I added the link to the documentation for <command> and the quote. It mentioned that you can call sh -c to do such a thing.
            – Raphael Ahrens
            Sep 21 '16 at 14:48












            up vote
            0
            down vote













            If you do not mind the order and the fact that all of these will be executed more or less at once you can do:



            <keybind key="XF86AudioRaiseVolumen">
            <action name="Execute">
            <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5%</command>
            </action>

            <action name="Execute">
            <command>pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5%</command>
            </action>

            <action name="Execute">
            <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%</command>
            </action>
            </keybind>




            share








            New contributor




            Michal Ambroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















              up vote
              0
              down vote













              If you do not mind the order and the fact that all of these will be executed more or less at once you can do:



              <keybind key="XF86AudioRaiseVolumen">
              <action name="Execute">
              <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5%</command>
              </action>

              <action name="Execute">
              <command>pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5%</command>
              </action>

              <action name="Execute">
              <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%</command>
              </action>
              </keybind>




              share








              New contributor




              Michal Ambroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.



















                up vote
                0
                down vote










                up vote
                0
                down vote









                If you do not mind the order and the fact that all of these will be executed more or less at once you can do:



                <keybind key="XF86AudioRaiseVolumen">
                <action name="Execute">
                <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5%</command>
                </action>

                <action name="Execute">
                <command>pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5%</command>
                </action>

                <action name="Execute">
                <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%</command>
                </action>
                </keybind>




                share








                New contributor




                Michal Ambroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                If you do not mind the order and the fact that all of these will be executed more or less at once you can do:



                <keybind key="XF86AudioRaiseVolumen">
                <action name="Execute">
                <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.multichannel-output +5%</command>
                </action>

                <action name="Execute">
                <command>pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +5%</command>
                </action>

                <action name="Execute">
                <command>pactl set-sink-volume alsa_output.usb-Focusrite_Scarlett_2i4_USB-00.analog-surround-40 +5%</command>
                </action>
                </keybind>





                share








                New contributor




                Michal Ambroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.








                share


                share






                New contributor




                Michal Ambroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 1 min ago









                Michal Ambroz

                1




                1




                New contributor




                Michal Ambroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Michal Ambroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Michal Ambroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f307611%2fopenbox-multiple-commands-separated-with-for-one-keypress%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay