As I mentioned in the last post, I've switched to the i3 window manager. After fixing the Caps Lock key, the next order of business is getting the audio keys on my multimedia keyboard to control audio output. (It's nice to be able to quickly mute or pause when the phone rings, for example.)
This turns out to be pretty easy. I used xev to figure out the keysyms for the audio keys, and then added bindings to ~/.i3/config:
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume 0 +5% bindsym XF86AudioLowerVolume exec pactl set-sink-volume 0 -- -5% bindsym XF86AudioMute exec ~/bin/toggle-mute bindsym XF86AudioPlay exec clementine --play-pause bindsym XF86AudioStop exec clementine --stop bindsym XF86AudioPrev exec clementine --previous bindsym XF86AudioNext exec clementine --next
As you can see, I prefer clementine as an audio player. If you have something different that you like, look up the command line method for controlling the player.
The pactl command controls pulse audio. The toggle script is something I threw together because pactl doesn't support toggling the mute, you have to tell it mute or unmute:
1 2 3 | #!/bin/bash toggle=$((pactl list sinks | grep -q Mute:.no && echo 1) || echo 0) pactl set-sink-mute 0 $toggle |
I only have one sink, so if you have more than one, you'll need to adjust the script.