How to use command line to change volume?












66














I am trying to control the volume using my programming script. How can I do the following in Fedora 15, Ubuntu linux?




  1. Mute/ Unmute

  2. Volume up and volume down


Note: Please note that I use a web USB microphone/speaker and also Analogue microphone/speaker. I want to apply to all to be sure.










share|improve this question




















  • 1




    If anyone's coming here from lubuntu to fix their volume control buttons, putting <command>amixer -D pulse sset Master 3%+ unmute</command> in the relevant keybind of ~/.config/openbox/lubuntu-rc.xml and then running openbox --reconfigure fixed it for me
    – rhombidodecahedron
    Sep 7 '16 at 19:49
















66














I am trying to control the volume using my programming script. How can I do the following in Fedora 15, Ubuntu linux?




  1. Mute/ Unmute

  2. Volume up and volume down


Note: Please note that I use a web USB microphone/speaker and also Analogue microphone/speaker. I want to apply to all to be sure.










share|improve this question




















  • 1




    If anyone's coming here from lubuntu to fix their volume control buttons, putting <command>amixer -D pulse sset Master 3%+ unmute</command> in the relevant keybind of ~/.config/openbox/lubuntu-rc.xml and then running openbox --reconfigure fixed it for me
    – rhombidodecahedron
    Sep 7 '16 at 19:49














66












66








66


18





I am trying to control the volume using my programming script. How can I do the following in Fedora 15, Ubuntu linux?




  1. Mute/ Unmute

  2. Volume up and volume down


Note: Please note that I use a web USB microphone/speaker and also Analogue microphone/speaker. I want to apply to all to be sure.










share|improve this question















I am trying to control the volume using my programming script. How can I do the following in Fedora 15, Ubuntu linux?




  1. Mute/ Unmute

  2. Volume up and volume down


Note: Please note that I use a web USB microphone/speaker and also Analogue microphone/speaker. I want to apply to all to be sure.







linux command-line audio alsa






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 20 '11 at 23:49









Gilles

528k12810571583




528k12810571583










asked Sep 20 '11 at 10:07









YumYumYum

1,584123565




1,584123565








  • 1




    If anyone's coming here from lubuntu to fix their volume control buttons, putting <command>amixer -D pulse sset Master 3%+ unmute</command> in the relevant keybind of ~/.config/openbox/lubuntu-rc.xml and then running openbox --reconfigure fixed it for me
    – rhombidodecahedron
    Sep 7 '16 at 19:49














  • 1




    If anyone's coming here from lubuntu to fix their volume control buttons, putting <command>amixer -D pulse sset Master 3%+ unmute</command> in the relevant keybind of ~/.config/openbox/lubuntu-rc.xml and then running openbox --reconfigure fixed it for me
    – rhombidodecahedron
    Sep 7 '16 at 19:49








1




1




If anyone's coming here from lubuntu to fix their volume control buttons, putting <command>amixer -D pulse sset Master 3%+ unmute</command> in the relevant keybind of ~/.config/openbox/lubuntu-rc.xml and then running openbox --reconfigure fixed it for me
– rhombidodecahedron
Sep 7 '16 at 19:49




If anyone's coming here from lubuntu to fix their volume control buttons, putting <command>amixer -D pulse sset Master 3%+ unmute</command> in the relevant keybind of ~/.config/openbox/lubuntu-rc.xml and then running openbox --reconfigure fixed it for me
– rhombidodecahedron
Sep 7 '16 at 19:49










8 Answers
8






active

oldest

votes


















76














You can use amixer. It's in the alsa-utils package on ubuntu/debian.



Run it without parameters to get an overview about your devices.



amixer


Then use the set command to set the volumn.
For example to set the master channel to 50%:



amixer set Master 50%


Note the "%" sign, without it it will treat the value as 0 - 65536 level.






share|improve this answer



















  • 4




    Thanks! there are two ways to do this 1. As your excellent example: amixer set Master mute; amixer set Master unmute; 2. yum -y install xdotool; xdotool key XF86AudioRaiseVolume; xdotool key XF86AudioLowerVolume;
    – YumYumYum
    Sep 20 '11 at 11:05






  • 14




    And as an addition, you can increase or decrease the volume by amixer set Master 10%+ and amixer set Master 10%-
    – user
    Apr 7 '12 at 21:25






  • 2




    This does not work in Ubuntu.
    – Cerin
    May 24 '12 at 14:37






  • 2




    I disagree @Cerin. This works on Ubuntu LTS 12 right now. Note that the M in master is case sensitive (must be uppercase).
    – ashes999
    Apr 9 '14 at 16:35






  • 5




    Cerin is right. This does not work. What works is : amixer -D pulse sset Master 50%
    – shivams
    May 7 '15 at 11:22



















28














To Mute:



amixer -D pulse sset Master mute



To Unmute:



amixer -D pulse sset Master unmute



To turn volume up 5%:



amixer -D pulse sset Master 5%+



To turn volume down 5%:



amixer -D pulse sset Master 5%-






share|improve this answer

















  • 1




    You can also add unmute to latter commands to automatically unmute when you change volume (for convenience): amixer -D pulse sset Master unmute 5%+
    – Roman Golyshev
    Oct 6 at 23:06





















14














pactl/pacmd (unlike amixer) allows to increase volume over 100% :-).



pactl set-sink-mute 0 toggle  # toggle mute
pactl set-sink-volume 0 0 # mute (force)
pactl set-sink-volume 0 100% # max
pactl set-sink-volume 0 +5% # +5% (up)
pactl set-sink-volume 0 -5% # -5% (down)


Manual settings over 100% is possible in pavucontrol (unlike alsamixer).



NOTE: If you want to share the same commands on different hosts with different sinks, you can use @DEFAULT_SINK@ as a sink instead of number 0:



pactl set-sink-volume @DEFAULT_SINK@ +5%


You set your default sink with pactl set-default-sink my-sink-name (list names with pactl list short sinks).



UPDATE: added toggle mute (thanks to Don Joe).



Source: askubuntu.com, wiki.archlinux.org.






share|improve this answer































    3














    if the user has muted the device you have to 'unmute' it. otherwise setting the percentage will work but the sound is still off



    amixer set 'Master' 100% unmute
    /usr/bin/amixer set 'PCM' 100% unmute





    share|improve this answer





























      3














      pevik's answer is almost correct for PulseAudio, with two things to mention:




      • the negative volume change command will generate an error because the minus-something portion of it will be interpreted as a separate (unrecognized) option; you need to turn off option parsing with a double-minus somewhere before the negative number, e.g. " -- -5%"


      • the true mute state is something that should be possible to toggle with the same key, which won't work if you're just setting the volume to a fixed value of 0, so the right command for that would be:



      pactl set-sink-mute @DEFAULT_SINK@ toggle



      LE:
      Whether the first hint is applicable may depend on the version of PulseAudio you're running or on something else in the distro - I notice that on Ubuntu 16 it works without the "--" and fails if I add "--" in front of the negative percentage.






      share|improve this answer























      • very good thx, that makes it perfect when we change window managers a lot on the fly for better gaming fps, so I use xbindkeys-config and I dont even have to restart X :) (lol the smile... no pun intended lol)
        – Aquarius Power
        Aug 31 '17 at 0:08



















      3














      Higher volume:



      amixer set Master 3%+


      Lower volume:



      amixer set Master 3%-


      Mute toggle:



      amixer set Master toggle


      Example keybindings for i3/sway, the commands are after exec:



      bindsym XF86AudioRaiseVolume exec amixer set Master 3%+
      bindsym XF86AudioLowerVolume exec amixer set Master 3%-
      bindsym XF86AudioMute exec amixer set Master toggle
      bindsym Ctrl+$alt+Up exec amixer set Master 3%+
      bindsym Ctrl+$alt+Down exec amixer set Master 3%-





      share|improve this answer





























        2














        amixer worked for me but I didn't get the nice animation that I get when I press the volume up button on my keyboard.



        I decided to use xte to directly press that key from the command line:



        Volume up:
        xte 'key 0x1008ff13'



        Volume down:
        xte 'key 0x1008ff11'



        Mute:
        xte 'key 0x1008ff12'



        I figured out the keysym (that hex number) by using xev.



        sudo apt-get install xbindkeys xautomation
        xev


        and then press the volume up button on your keyboard to get the keysym. The key sym may vary from system to system so finding it from xev will be the most reliable way.



        The result looks like this for me:




        KeyRelease event, serial 37, synthetic NO, window 0x2c00001,
        root 0xef, subw 0x0, time 6660080, (566,573), root:(664,651),
        state 0x0, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
        XLookupString gives 0 bytes:
        XFilterEvent returns: False







        share|improve this answer





























          0














          sudo apt-get install xbindkeys xautomation
          xev






          share|improve this answer








          New contributor




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


















          • Please don't repeat a previous answer; instead, earn enough reputation to upvote that answer. Thank you, and welcome to the site!
            – Jeff Schaller
            21 mins ago











          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          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%2f21089%2fhow-to-use-command-line-to-change-volume%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          8 Answers
          8






          active

          oldest

          votes








          8 Answers
          8






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          76














          You can use amixer. It's in the alsa-utils package on ubuntu/debian.



          Run it without parameters to get an overview about your devices.



          amixer


          Then use the set command to set the volumn.
          For example to set the master channel to 50%:



          amixer set Master 50%


          Note the "%" sign, without it it will treat the value as 0 - 65536 level.






          share|improve this answer



















          • 4




            Thanks! there are two ways to do this 1. As your excellent example: amixer set Master mute; amixer set Master unmute; 2. yum -y install xdotool; xdotool key XF86AudioRaiseVolume; xdotool key XF86AudioLowerVolume;
            – YumYumYum
            Sep 20 '11 at 11:05






          • 14




            And as an addition, you can increase or decrease the volume by amixer set Master 10%+ and amixer set Master 10%-
            – user
            Apr 7 '12 at 21:25






          • 2




            This does not work in Ubuntu.
            – Cerin
            May 24 '12 at 14:37






          • 2




            I disagree @Cerin. This works on Ubuntu LTS 12 right now. Note that the M in master is case sensitive (must be uppercase).
            – ashes999
            Apr 9 '14 at 16:35






          • 5




            Cerin is right. This does not work. What works is : amixer -D pulse sset Master 50%
            – shivams
            May 7 '15 at 11:22
















          76














          You can use amixer. It's in the alsa-utils package on ubuntu/debian.



          Run it without parameters to get an overview about your devices.



          amixer


          Then use the set command to set the volumn.
          For example to set the master channel to 50%:



          amixer set Master 50%


          Note the "%" sign, without it it will treat the value as 0 - 65536 level.






          share|improve this answer



















          • 4




            Thanks! there are two ways to do this 1. As your excellent example: amixer set Master mute; amixer set Master unmute; 2. yum -y install xdotool; xdotool key XF86AudioRaiseVolume; xdotool key XF86AudioLowerVolume;
            – YumYumYum
            Sep 20 '11 at 11:05






          • 14




            And as an addition, you can increase or decrease the volume by amixer set Master 10%+ and amixer set Master 10%-
            – user
            Apr 7 '12 at 21:25






          • 2




            This does not work in Ubuntu.
            – Cerin
            May 24 '12 at 14:37






          • 2




            I disagree @Cerin. This works on Ubuntu LTS 12 right now. Note that the M in master is case sensitive (must be uppercase).
            – ashes999
            Apr 9 '14 at 16:35






          • 5




            Cerin is right. This does not work. What works is : amixer -D pulse sset Master 50%
            – shivams
            May 7 '15 at 11:22














          76












          76








          76






          You can use amixer. It's in the alsa-utils package on ubuntu/debian.



          Run it without parameters to get an overview about your devices.



          amixer


          Then use the set command to set the volumn.
          For example to set the master channel to 50%:



          amixer set Master 50%


          Note the "%" sign, without it it will treat the value as 0 - 65536 level.






          share|improve this answer














          You can use amixer. It's in the alsa-utils package on ubuntu/debian.



          Run it without parameters to get an overview about your devices.



          amixer


          Then use the set command to set the volumn.
          For example to set the master channel to 50%:



          amixer set Master 50%


          Note the "%" sign, without it it will treat the value as 0 - 65536 level.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 10 '16 at 19:04









          zhur

          134




          134










          answered Sep 20 '11 at 10:33









          Dario Seidl

          1,3231210




          1,3231210








          • 4




            Thanks! there are two ways to do this 1. As your excellent example: amixer set Master mute; amixer set Master unmute; 2. yum -y install xdotool; xdotool key XF86AudioRaiseVolume; xdotool key XF86AudioLowerVolume;
            – YumYumYum
            Sep 20 '11 at 11:05






          • 14




            And as an addition, you can increase or decrease the volume by amixer set Master 10%+ and amixer set Master 10%-
            – user
            Apr 7 '12 at 21:25






          • 2




            This does not work in Ubuntu.
            – Cerin
            May 24 '12 at 14:37






          • 2




            I disagree @Cerin. This works on Ubuntu LTS 12 right now. Note that the M in master is case sensitive (must be uppercase).
            – ashes999
            Apr 9 '14 at 16:35






          • 5




            Cerin is right. This does not work. What works is : amixer -D pulse sset Master 50%
            – shivams
            May 7 '15 at 11:22














          • 4




            Thanks! there are two ways to do this 1. As your excellent example: amixer set Master mute; amixer set Master unmute; 2. yum -y install xdotool; xdotool key XF86AudioRaiseVolume; xdotool key XF86AudioLowerVolume;
            – YumYumYum
            Sep 20 '11 at 11:05






          • 14




            And as an addition, you can increase or decrease the volume by amixer set Master 10%+ and amixer set Master 10%-
            – user
            Apr 7 '12 at 21:25






          • 2




            This does not work in Ubuntu.
            – Cerin
            May 24 '12 at 14:37






          • 2




            I disagree @Cerin. This works on Ubuntu LTS 12 right now. Note that the M in master is case sensitive (must be uppercase).
            – ashes999
            Apr 9 '14 at 16:35






          • 5




            Cerin is right. This does not work. What works is : amixer -D pulse sset Master 50%
            – shivams
            May 7 '15 at 11:22








          4




          4




          Thanks! there are two ways to do this 1. As your excellent example: amixer set Master mute; amixer set Master unmute; 2. yum -y install xdotool; xdotool key XF86AudioRaiseVolume; xdotool key XF86AudioLowerVolume;
          – YumYumYum
          Sep 20 '11 at 11:05




          Thanks! there are two ways to do this 1. As your excellent example: amixer set Master mute; amixer set Master unmute; 2. yum -y install xdotool; xdotool key XF86AudioRaiseVolume; xdotool key XF86AudioLowerVolume;
          – YumYumYum
          Sep 20 '11 at 11:05




          14




          14




          And as an addition, you can increase or decrease the volume by amixer set Master 10%+ and amixer set Master 10%-
          – user
          Apr 7 '12 at 21:25




          And as an addition, you can increase or decrease the volume by amixer set Master 10%+ and amixer set Master 10%-
          – user
          Apr 7 '12 at 21:25




          2




          2




          This does not work in Ubuntu.
          – Cerin
          May 24 '12 at 14:37




          This does not work in Ubuntu.
          – Cerin
          May 24 '12 at 14:37




          2




          2




          I disagree @Cerin. This works on Ubuntu LTS 12 right now. Note that the M in master is case sensitive (must be uppercase).
          – ashes999
          Apr 9 '14 at 16:35




          I disagree @Cerin. This works on Ubuntu LTS 12 right now. Note that the M in master is case sensitive (must be uppercase).
          – ashes999
          Apr 9 '14 at 16:35




          5




          5




          Cerin is right. This does not work. What works is : amixer -D pulse sset Master 50%
          – shivams
          May 7 '15 at 11:22




          Cerin is right. This does not work. What works is : amixer -D pulse sset Master 50%
          – shivams
          May 7 '15 at 11:22













          28














          To Mute:



          amixer -D pulse sset Master mute



          To Unmute:



          amixer -D pulse sset Master unmute



          To turn volume up 5%:



          amixer -D pulse sset Master 5%+



          To turn volume down 5%:



          amixer -D pulse sset Master 5%-






          share|improve this answer

















          • 1




            You can also add unmute to latter commands to automatically unmute when you change volume (for convenience): amixer -D pulse sset Master unmute 5%+
            – Roman Golyshev
            Oct 6 at 23:06


















          28














          To Mute:



          amixer -D pulse sset Master mute



          To Unmute:



          amixer -D pulse sset Master unmute



          To turn volume up 5%:



          amixer -D pulse sset Master 5%+



          To turn volume down 5%:



          amixer -D pulse sset Master 5%-






          share|improve this answer

















          • 1




            You can also add unmute to latter commands to automatically unmute when you change volume (for convenience): amixer -D pulse sset Master unmute 5%+
            – Roman Golyshev
            Oct 6 at 23:06
















          28












          28








          28






          To Mute:



          amixer -D pulse sset Master mute



          To Unmute:



          amixer -D pulse sset Master unmute



          To turn volume up 5%:



          amixer -D pulse sset Master 5%+



          To turn volume down 5%:



          amixer -D pulse sset Master 5%-






          share|improve this answer












          To Mute:



          amixer -D pulse sset Master mute



          To Unmute:



          amixer -D pulse sset Master unmute



          To turn volume up 5%:



          amixer -D pulse sset Master 5%+



          To turn volume down 5%:



          amixer -D pulse sset Master 5%-







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 3 '15 at 4:28









          Eric Terry

          38134




          38134








          • 1




            You can also add unmute to latter commands to automatically unmute when you change volume (for convenience): amixer -D pulse sset Master unmute 5%+
            – Roman Golyshev
            Oct 6 at 23:06
















          • 1




            You can also add unmute to latter commands to automatically unmute when you change volume (for convenience): amixer -D pulse sset Master unmute 5%+
            – Roman Golyshev
            Oct 6 at 23:06










          1




          1




          You can also add unmute to latter commands to automatically unmute when you change volume (for convenience): amixer -D pulse sset Master unmute 5%+
          – Roman Golyshev
          Oct 6 at 23:06






          You can also add unmute to latter commands to automatically unmute when you change volume (for convenience): amixer -D pulse sset Master unmute 5%+
          – Roman Golyshev
          Oct 6 at 23:06













          14














          pactl/pacmd (unlike amixer) allows to increase volume over 100% :-).



          pactl set-sink-mute 0 toggle  # toggle mute
          pactl set-sink-volume 0 0 # mute (force)
          pactl set-sink-volume 0 100% # max
          pactl set-sink-volume 0 +5% # +5% (up)
          pactl set-sink-volume 0 -5% # -5% (down)


          Manual settings over 100% is possible in pavucontrol (unlike alsamixer).



          NOTE: If you want to share the same commands on different hosts with different sinks, you can use @DEFAULT_SINK@ as a sink instead of number 0:



          pactl set-sink-volume @DEFAULT_SINK@ +5%


          You set your default sink with pactl set-default-sink my-sink-name (list names with pactl list short sinks).



          UPDATE: added toggle mute (thanks to Don Joe).



          Source: askubuntu.com, wiki.archlinux.org.






          share|improve this answer




























            14














            pactl/pacmd (unlike amixer) allows to increase volume over 100% :-).



            pactl set-sink-mute 0 toggle  # toggle mute
            pactl set-sink-volume 0 0 # mute (force)
            pactl set-sink-volume 0 100% # max
            pactl set-sink-volume 0 +5% # +5% (up)
            pactl set-sink-volume 0 -5% # -5% (down)


            Manual settings over 100% is possible in pavucontrol (unlike alsamixer).



            NOTE: If you want to share the same commands on different hosts with different sinks, you can use @DEFAULT_SINK@ as a sink instead of number 0:



            pactl set-sink-volume @DEFAULT_SINK@ +5%


            You set your default sink with pactl set-default-sink my-sink-name (list names with pactl list short sinks).



            UPDATE: added toggle mute (thanks to Don Joe).



            Source: askubuntu.com, wiki.archlinux.org.






            share|improve this answer


























              14












              14








              14






              pactl/pacmd (unlike amixer) allows to increase volume over 100% :-).



              pactl set-sink-mute 0 toggle  # toggle mute
              pactl set-sink-volume 0 0 # mute (force)
              pactl set-sink-volume 0 100% # max
              pactl set-sink-volume 0 +5% # +5% (up)
              pactl set-sink-volume 0 -5% # -5% (down)


              Manual settings over 100% is possible in pavucontrol (unlike alsamixer).



              NOTE: If you want to share the same commands on different hosts with different sinks, you can use @DEFAULT_SINK@ as a sink instead of number 0:



              pactl set-sink-volume @DEFAULT_SINK@ +5%


              You set your default sink with pactl set-default-sink my-sink-name (list names with pactl list short sinks).



              UPDATE: added toggle mute (thanks to Don Joe).



              Source: askubuntu.com, wiki.archlinux.org.






              share|improve this answer














              pactl/pacmd (unlike amixer) allows to increase volume over 100% :-).



              pactl set-sink-mute 0 toggle  # toggle mute
              pactl set-sink-volume 0 0 # mute (force)
              pactl set-sink-volume 0 100% # max
              pactl set-sink-volume 0 +5% # +5% (up)
              pactl set-sink-volume 0 -5% # -5% (down)


              Manual settings over 100% is possible in pavucontrol (unlike alsamixer).



              NOTE: If you want to share the same commands on different hosts with different sinks, you can use @DEFAULT_SINK@ as a sink instead of number 0:



              pactl set-sink-volume @DEFAULT_SINK@ +5%


              You set your default sink with pactl set-default-sink my-sink-name (list names with pactl list short sinks).



              UPDATE: added toggle mute (thanks to Don Joe).



              Source: askubuntu.com, wiki.archlinux.org.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Feb 26 at 8:49

























              answered Sep 1 '16 at 19:05









              pevik

              598414




              598414























                  3














                  if the user has muted the device you have to 'unmute' it. otherwise setting the percentage will work but the sound is still off



                  amixer set 'Master' 100% unmute
                  /usr/bin/amixer set 'PCM' 100% unmute





                  share|improve this answer


























                    3














                    if the user has muted the device you have to 'unmute' it. otherwise setting the percentage will work but the sound is still off



                    amixer set 'Master' 100% unmute
                    /usr/bin/amixer set 'PCM' 100% unmute





                    share|improve this answer
























                      3












                      3








                      3






                      if the user has muted the device you have to 'unmute' it. otherwise setting the percentage will work but the sound is still off



                      amixer set 'Master' 100% unmute
                      /usr/bin/amixer set 'PCM' 100% unmute





                      share|improve this answer












                      if the user has muted the device you have to 'unmute' it. otherwise setting the percentage will work but the sound is still off



                      amixer set 'Master' 100% unmute
                      /usr/bin/amixer set 'PCM' 100% unmute






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Feb 4 '17 at 12:29









                      Guest

                      311




                      311























                          3














                          pevik's answer is almost correct for PulseAudio, with two things to mention:




                          • the negative volume change command will generate an error because the minus-something portion of it will be interpreted as a separate (unrecognized) option; you need to turn off option parsing with a double-minus somewhere before the negative number, e.g. " -- -5%"


                          • the true mute state is something that should be possible to toggle with the same key, which won't work if you're just setting the volume to a fixed value of 0, so the right command for that would be:



                          pactl set-sink-mute @DEFAULT_SINK@ toggle



                          LE:
                          Whether the first hint is applicable may depend on the version of PulseAudio you're running or on something else in the distro - I notice that on Ubuntu 16 it works without the "--" and fails if I add "--" in front of the negative percentage.






                          share|improve this answer























                          • very good thx, that makes it perfect when we change window managers a lot on the fly for better gaming fps, so I use xbindkeys-config and I dont even have to restart X :) (lol the smile... no pun intended lol)
                            – Aquarius Power
                            Aug 31 '17 at 0:08
















                          3














                          pevik's answer is almost correct for PulseAudio, with two things to mention:




                          • the negative volume change command will generate an error because the minus-something portion of it will be interpreted as a separate (unrecognized) option; you need to turn off option parsing with a double-minus somewhere before the negative number, e.g. " -- -5%"


                          • the true mute state is something that should be possible to toggle with the same key, which won't work if you're just setting the volume to a fixed value of 0, so the right command for that would be:



                          pactl set-sink-mute @DEFAULT_SINK@ toggle



                          LE:
                          Whether the first hint is applicable may depend on the version of PulseAudio you're running or on something else in the distro - I notice that on Ubuntu 16 it works without the "--" and fails if I add "--" in front of the negative percentage.






                          share|improve this answer























                          • very good thx, that makes it perfect when we change window managers a lot on the fly for better gaming fps, so I use xbindkeys-config and I dont even have to restart X :) (lol the smile... no pun intended lol)
                            – Aquarius Power
                            Aug 31 '17 at 0:08














                          3












                          3








                          3






                          pevik's answer is almost correct for PulseAudio, with two things to mention:




                          • the negative volume change command will generate an error because the minus-something portion of it will be interpreted as a separate (unrecognized) option; you need to turn off option parsing with a double-minus somewhere before the negative number, e.g. " -- -5%"


                          • the true mute state is something that should be possible to toggle with the same key, which won't work if you're just setting the volume to a fixed value of 0, so the right command for that would be:



                          pactl set-sink-mute @DEFAULT_SINK@ toggle



                          LE:
                          Whether the first hint is applicable may depend on the version of PulseAudio you're running or on something else in the distro - I notice that on Ubuntu 16 it works without the "--" and fails if I add "--" in front of the negative percentage.






                          share|improve this answer














                          pevik's answer is almost correct for PulseAudio, with two things to mention:




                          • the negative volume change command will generate an error because the minus-something portion of it will be interpreted as a separate (unrecognized) option; you need to turn off option parsing with a double-minus somewhere before the negative number, e.g. " -- -5%"


                          • the true mute state is something that should be possible to toggle with the same key, which won't work if you're just setting the volume to a fixed value of 0, so the right command for that would be:



                          pactl set-sink-mute @DEFAULT_SINK@ toggle



                          LE:
                          Whether the first hint is applicable may depend on the version of PulseAudio you're running or on something else in the distro - I notice that on Ubuntu 16 it works without the "--" and fails if I add "--" in front of the negative percentage.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Feb 25 at 19:14

























                          answered Jul 15 '17 at 20:45









                          Don Joe

                          767




                          767












                          • very good thx, that makes it perfect when we change window managers a lot on the fly for better gaming fps, so I use xbindkeys-config and I dont even have to restart X :) (lol the smile... no pun intended lol)
                            – Aquarius Power
                            Aug 31 '17 at 0:08


















                          • very good thx, that makes it perfect when we change window managers a lot on the fly for better gaming fps, so I use xbindkeys-config and I dont even have to restart X :) (lol the smile... no pun intended lol)
                            – Aquarius Power
                            Aug 31 '17 at 0:08
















                          very good thx, that makes it perfect when we change window managers a lot on the fly for better gaming fps, so I use xbindkeys-config and I dont even have to restart X :) (lol the smile... no pun intended lol)
                          – Aquarius Power
                          Aug 31 '17 at 0:08




                          very good thx, that makes it perfect when we change window managers a lot on the fly for better gaming fps, so I use xbindkeys-config and I dont even have to restart X :) (lol the smile... no pun intended lol)
                          – Aquarius Power
                          Aug 31 '17 at 0:08











                          3














                          Higher volume:



                          amixer set Master 3%+


                          Lower volume:



                          amixer set Master 3%-


                          Mute toggle:



                          amixer set Master toggle


                          Example keybindings for i3/sway, the commands are after exec:



                          bindsym XF86AudioRaiseVolume exec amixer set Master 3%+
                          bindsym XF86AudioLowerVolume exec amixer set Master 3%-
                          bindsym XF86AudioMute exec amixer set Master toggle
                          bindsym Ctrl+$alt+Up exec amixer set Master 3%+
                          bindsym Ctrl+$alt+Down exec amixer set Master 3%-





                          share|improve this answer


























                            3














                            Higher volume:



                            amixer set Master 3%+


                            Lower volume:



                            amixer set Master 3%-


                            Mute toggle:



                            amixer set Master toggle


                            Example keybindings for i3/sway, the commands are after exec:



                            bindsym XF86AudioRaiseVolume exec amixer set Master 3%+
                            bindsym XF86AudioLowerVolume exec amixer set Master 3%-
                            bindsym XF86AudioMute exec amixer set Master toggle
                            bindsym Ctrl+$alt+Up exec amixer set Master 3%+
                            bindsym Ctrl+$alt+Down exec amixer set Master 3%-





                            share|improve this answer
























                              3












                              3








                              3






                              Higher volume:



                              amixer set Master 3%+


                              Lower volume:



                              amixer set Master 3%-


                              Mute toggle:



                              amixer set Master toggle


                              Example keybindings for i3/sway, the commands are after exec:



                              bindsym XF86AudioRaiseVolume exec amixer set Master 3%+
                              bindsym XF86AudioLowerVolume exec amixer set Master 3%-
                              bindsym XF86AudioMute exec amixer set Master toggle
                              bindsym Ctrl+$alt+Up exec amixer set Master 3%+
                              bindsym Ctrl+$alt+Down exec amixer set Master 3%-





                              share|improve this answer












                              Higher volume:



                              amixer set Master 3%+


                              Lower volume:



                              amixer set Master 3%-


                              Mute toggle:



                              amixer set Master toggle


                              Example keybindings for i3/sway, the commands are after exec:



                              bindsym XF86AudioRaiseVolume exec amixer set Master 3%+
                              bindsym XF86AudioLowerVolume exec amixer set Master 3%-
                              bindsym XF86AudioMute exec amixer set Master toggle
                              bindsym Ctrl+$alt+Up exec amixer set Master 3%+
                              bindsym Ctrl+$alt+Down exec amixer set Master 3%-






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Feb 25 at 19:24









                              Alexander

                              5,86822043




                              5,86822043























                                  2














                                  amixer worked for me but I didn't get the nice animation that I get when I press the volume up button on my keyboard.



                                  I decided to use xte to directly press that key from the command line:



                                  Volume up:
                                  xte 'key 0x1008ff13'



                                  Volume down:
                                  xte 'key 0x1008ff11'



                                  Mute:
                                  xte 'key 0x1008ff12'



                                  I figured out the keysym (that hex number) by using xev.



                                  sudo apt-get install xbindkeys xautomation
                                  xev


                                  and then press the volume up button on your keyboard to get the keysym. The key sym may vary from system to system so finding it from xev will be the most reliable way.



                                  The result looks like this for me:




                                  KeyRelease event, serial 37, synthetic NO, window 0x2c00001,
                                  root 0xef, subw 0x0, time 6660080, (566,573), root:(664,651),
                                  state 0x0, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
                                  XLookupString gives 0 bytes:
                                  XFilterEvent returns: False







                                  share|improve this answer


























                                    2














                                    amixer worked for me but I didn't get the nice animation that I get when I press the volume up button on my keyboard.



                                    I decided to use xte to directly press that key from the command line:



                                    Volume up:
                                    xte 'key 0x1008ff13'



                                    Volume down:
                                    xte 'key 0x1008ff11'



                                    Mute:
                                    xte 'key 0x1008ff12'



                                    I figured out the keysym (that hex number) by using xev.



                                    sudo apt-get install xbindkeys xautomation
                                    xev


                                    and then press the volume up button on your keyboard to get the keysym. The key sym may vary from system to system so finding it from xev will be the most reliable way.



                                    The result looks like this for me:




                                    KeyRelease event, serial 37, synthetic NO, window 0x2c00001,
                                    root 0xef, subw 0x0, time 6660080, (566,573), root:(664,651),
                                    state 0x0, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
                                    XLookupString gives 0 bytes:
                                    XFilterEvent returns: False







                                    share|improve this answer
























                                      2












                                      2








                                      2






                                      amixer worked for me but I didn't get the nice animation that I get when I press the volume up button on my keyboard.



                                      I decided to use xte to directly press that key from the command line:



                                      Volume up:
                                      xte 'key 0x1008ff13'



                                      Volume down:
                                      xte 'key 0x1008ff11'



                                      Mute:
                                      xte 'key 0x1008ff12'



                                      I figured out the keysym (that hex number) by using xev.



                                      sudo apt-get install xbindkeys xautomation
                                      xev


                                      and then press the volume up button on your keyboard to get the keysym. The key sym may vary from system to system so finding it from xev will be the most reliable way.



                                      The result looks like this for me:




                                      KeyRelease event, serial 37, synthetic NO, window 0x2c00001,
                                      root 0xef, subw 0x0, time 6660080, (566,573), root:(664,651),
                                      state 0x0, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
                                      XLookupString gives 0 bytes:
                                      XFilterEvent returns: False







                                      share|improve this answer












                                      amixer worked for me but I didn't get the nice animation that I get when I press the volume up button on my keyboard.



                                      I decided to use xte to directly press that key from the command line:



                                      Volume up:
                                      xte 'key 0x1008ff13'



                                      Volume down:
                                      xte 'key 0x1008ff11'



                                      Mute:
                                      xte 'key 0x1008ff12'



                                      I figured out the keysym (that hex number) by using xev.



                                      sudo apt-get install xbindkeys xautomation
                                      xev


                                      and then press the volume up button on your keyboard to get the keysym. The key sym may vary from system to system so finding it from xev will be the most reliable way.



                                      The result looks like this for me:




                                      KeyRelease event, serial 37, synthetic NO, window 0x2c00001,
                                      root 0xef, subw 0x0, time 6660080, (566,573), root:(664,651),
                                      state 0x0, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
                                      XLookupString gives 0 bytes:
                                      XFilterEvent returns: False








                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Oct 26 '17 at 13:17









                                      Sami Start

                                      1212




                                      1212























                                          0














                                          sudo apt-get install xbindkeys xautomation
                                          xev






                                          share|improve this answer








                                          New contributor




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


















                                          • Please don't repeat a previous answer; instead, earn enough reputation to upvote that answer. Thank you, and welcome to the site!
                                            – Jeff Schaller
                                            21 mins ago
















                                          0














                                          sudo apt-get install xbindkeys xautomation
                                          xev






                                          share|improve this answer








                                          New contributor




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


















                                          • Please don't repeat a previous answer; instead, earn enough reputation to upvote that answer. Thank you, and welcome to the site!
                                            – Jeff Schaller
                                            21 mins ago














                                          0












                                          0








                                          0






                                          sudo apt-get install xbindkeys xautomation
                                          xev






                                          share|improve this answer








                                          New contributor




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









                                          sudo apt-get install xbindkeys xautomation
                                          xev







                                          share|improve this answer








                                          New contributor




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









                                          share|improve this answer



                                          share|improve this answer






                                          New contributor




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









                                          answered 1 hour ago









                                          Emma

                                          1




                                          1




                                          New contributor




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





                                          New contributor





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






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












                                          • Please don't repeat a previous answer; instead, earn enough reputation to upvote that answer. Thank you, and welcome to the site!
                                            – Jeff Schaller
                                            21 mins ago


















                                          • Please don't repeat a previous answer; instead, earn enough reputation to upvote that answer. Thank you, and welcome to the site!
                                            – Jeff Schaller
                                            21 mins ago
















                                          Please don't repeat a previous answer; instead, earn enough reputation to upvote that answer. Thank you, and welcome to the site!
                                          – Jeff Schaller
                                          21 mins ago




                                          Please don't repeat a previous answer; instead, earn enough reputation to upvote that answer. Thank you, and welcome to the site!
                                          – Jeff Schaller
                                          21 mins ago


















                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.





                                          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                          Please pay close attention to the following guidance:


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f21089%2fhow-to-use-command-line-to-change-volume%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Accessing regular linux commands in Huawei's Dopra Linux

                                          Can't connect RFCOMM socket: Host is down

                                          Kernel panic - not syncing: Fatal Exception in Interrupt