Normally a full desktop environment has all the tools to handle the sound. Most likely the laptop multimedia keys are already working fine - mute/increase/decrease volume etc.
But when something is not working, or if you're using a less user-friendly environment /window manager that has no out of the box multimedia keys support you need to do some setup on your own.
This is how you can handle the multimedia keys in i3wm/awesome wm/openbox etc.
The easiest thing is to bind the commands that do the stuff to the keys you want.
Therefore, you need to know the commands that do the stuff :)
In Ubuntu there's 2 ways: use alsa-utils or pulseaudio-utils. So install the corresponding package to be able to use their tools.
amixer -q -D pulse set Master 1+ toggle
Volume up:
amixer -q set Master 2+ unmute
Volume down:
amixer -q set Master 2- unmute
Note that this works for sink 1. Use pactl list short sinks to list yours and adjust the command.
pactl set-sink-mute 1 $((pactl list sinks | grep -q Mute:.yes && echo 0) || echo 1)
Volume up:
pactl set-sink-volume 1 +5%
Volume down:
pactl set-sink-volume 1 -- -5%
Now all you have to do is to use whatever method your WM has to bind the keys. You may want to use xbindkeys utility to have a WM-neutral keybindings. This is useful if you switch the WMs often.
But when something is not working, or if you're using a less user-friendly environment /window manager that has no out of the box multimedia keys support you need to do some setup on your own.
This is how you can handle the multimedia keys in i3wm/awesome wm/openbox etc.
The easiest thing is to bind the commands that do the stuff to the keys you want.
Therefore, you need to know the commands that do the stuff :)
In Ubuntu there's 2 ways: use alsa-utils or pulseaudio-utils. So install the corresponding package to be able to use their tools.
Alsa
Toggle mute:amixer -q -D pulse set Master 1+ toggle
Volume up:
amixer -q set Master 2+ unmute
Volume down:
amixer -q set Master 2- unmute
Pulseaudio
Toggle mute:Note that this works for sink 1. Use pactl list short sinks to list yours and adjust the command.
pactl set-sink-mute 1 $((pactl list sinks | grep -q Mute:.yes && echo 0) || echo 1)
Volume up:
pactl set-sink-volume 1 +5%
Volume down:
pactl set-sink-volume 1 -- -5%
Now all you have to do is to use whatever method your WM has to bind the keys. You may want to use xbindkeys utility to have a WM-neutral keybindings. This is useful if you switch the WMs often.
Add a comment