Pactl, pacmd, and mixer for adjusting volume from the terminal

I wanted to be able to change the volume of a sink from the terminal. I had been using mate-volume-control, but it was annoying to have to open that gui every time I wanted to change the volume. I had also previously been using mate-volume-control to toggle output sources (speaker/headphones). The headphones are on /dev/dsp3 - which I knew from the mate-volume-control.

I began by trying to use pactl, which seemed to be the most obvious choice. I identified the sink using pactl list sinks. The last sink in the last, Sink #3, was the sink I wanted to be using. I saw the volume set on left:right was 100%:100%. I was able to go into mate-volume-control and change the volume to 66%. I ran pactl list sinks and the volume was now 66%:66%.

When I attempted to do this from pactl using the set-sink-volume though, nothing happened. I ran pactl set-sink-volume 3 10. Since this is using integers and not percentage, this should have basically reduced the volume to zero. However, nothing happened and listing the sinks again showed that nothing, in fact, had changed.

Then I tried using mixer(8)(). I don't really understand this utility at all. I tried setting each device listed when running mixer to 10:10 ( mixer vol 10, etc.). These changes were made and running mixer again showed that whatever these devices are had been changed to volume 10:10. However, none of this actually affected the volume of the headphones.

Finally, I found pacmd on some Arch forums and gave that a shot. Running pacmd set-sink-volume 3 66000 finally brought the volume of the headphones back to around 100%.

I really don't know why things worked or didn't work here, but I wanted to bring this up in case anyone else has similar issues. I'd also welcome any explanations or suggestions.

On a sidenote, if I wanted to add history to the pacmd REPL, any recommendations for getting started on that?
 
A suggestion that does not involve opening any sound utilities is to set "hot keys" to Raise, Lower or Mute sound. The code to set this up is specific to the sound server you are using and the desktop. From your post, I assuming you are using Mate with the pulseaudio sound server.

If you are running a laptop, often there are Fn+Key combinations that produce "XF86AudioRaiseVolume". Here is the Arch Linux PulseAudio Wiki.
 
So you tried different outputs and numbers with mixer? mixer #, mixer speaker #, mixer pcm #. It could be because it's plugged in to the lineout jack, or the program is not working properly. The pcm option should work on all outputs.
 
Back
Top