5

Using mate and linux mint, I would like to create another keyboard shortcut to increase and decrease the volume.

Currently, I'm using custom keyboard bindings with mate-keybinding-properties.

I bought a wireless headset which includes buttons to change the volume. Those buttons works well if I reconfigure the keybindings, but I don't want to remove the ones with keyboard. That's why I would like to create another shortcut, but I can't find a command to do this in mate, or which one is used with the default settings.

I already found topics about amixer, but I'm not happy with it because it doesn't show the volume tooltip, and it resets the balance of my speakers when I try to increase it to more than 100%.

  • @slm That's not a duplicate. I wrote that I already know about amixer, and that's not what I'm searching for. – sebcap26 Mar 6 '14 at 21:22
  • Fair enough, I'll retract, in the future please link to these Q's if you can so that ppl know you've already reviewed them, otherwise I'm not entirely sure if you've seen them or not, and they do appear to be dups otherwise. – slm Mar 6 '14 at 21:28
3

You can use pactl to change the volume. Eg, to increase:

pactl set-sink-volume 0 +10%

And to decrease:

pactl set-sink-volume -- 0 -10%

You need the -- here to make pactl interpret the -10% as a postitional argument. The first number is the sink to use, this may not be 0 on your system. To list the possibilities:

pactl list short sinks
  • Thanks, but that does the same than amixer, it doesn't solve my problems. And the "+10%" is weird, I can't reach 100%. – sebcap26 Mar 7 '14 at 16:52
  • Interesting, works fine for me. You can do pacmd dump-volumes to see exactly what is happening. You can also specify integer values instead of percentages, if this helps. Eg - pactl set-sink-volume 0 +1000 – Graeme Mar 7 '14 at 17:25
  • @sebcap26, forgot to @ you in my last comment – Graeme Mar 7 '14 at 17:35
  • I don't have a dump-volumes option. That's really weird, if I try adding a value and not a percentage, it decreases the volume ... But only when the speakers are not balanced. It's not a problem because my headset will be balanced, so I consider it solved. Thanks ! – sebcap26 Mar 7 '14 at 18:34
  • @sebcap26, note that dump-volumes only works with pacmd, pactl doesn't have it. – Graeme Mar 7 '14 at 18:52
1

One alternative to the amixer command - which gives you the tooltip as well - is simulating the corresponding Media key press.

This can be done with xdotool (which you have to install (apt-get install xdotool) first):

xdotool key XF86AudioRaiseVolume
xdotool key XF86AudioLowerVolume

Works perfectly on Cinnamon.

0

Here is a script which I created for convenience. I have it it my PATH under name vu and use it like vu 10 to add 10% volume.

First it asks what is the speaker you are using (does not work when there is no sound playing). Then it raises the volume by 5%, or, if provided a parameter, by the specified amount. At the end it tells you the volume you are now hearing.

It's generally @Graeme's idea, but wrapped in a script.

I have written a very similar looking script (just change + for -) which turns the volume down and put it under the name vd.

#!/usr/bin/bash
MASTER_SINK=$(pactl list short sinks | grep "RUNNING" | awk '{print $1}')
if [ $# -eq 0 ]
then
    pactl set-sink-volume $MASTER_SINK +5%
else
    pactl set-sink-volume $MASTER_SINK +$@%
fi
pactl list sinks | grep -E "RUNNING|Volume" | grep -A1 "RUNNING" | grep -E -o "[[:digit:]]{1,5}%" | head -n1

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.