December 16, 2015

Adding Volume Controls to your Keyboard

Help! My keyboard volume buttons don't work anymore! That's how my adventure started. Actually it started with a whole bunch of funny punctuation characters uttered outloud. Then came the, "how do I do this? It's not supposed to be this confusing!"

Most people start by looking in the right place: Applications ⇒ Settings ⇒ Keyboard ⇒ Application Shortcuts but end up stymied when confronted with "Enter the command you want to trigger with a shortcut". Uh, how am I supposed to know that? Before we go adding a shortcut it's a good idea to see if it's already there and maybe just broken. Scroll through the list of existing shortcuts. The ones you are interested in are XF86AudioMute, XF86AudioLowerVolume, and XF86AudioRaiseVolume.

I've heard reports that editing them doesn't always work so begin by clicking on any of those you find and -Remove them. Now you'll add them, one by one. Click on +Add. You'll be prompted to enter a command and to press enter, followed by the opportunity to press the key that is the shortcut to that command. Here is a mapping of each command to each button:


    amixer -D pulse set Master +1 toggle      ⇔   XF86AudioMute
    amixer -D pulse set Master playback 3%-   ⇔   XF86AudioLowerVolume
    amixer -D pulse set Master playback 3%+   ⇔   XF86AudioRaiseVolume
  

The 3%± settings are not fixed in stone. These represent the size of the steps between up and down volume adjustments. I find a 3% step provides a very pleasant and gradual transition. If you're more the "small, medium, large" kind of person use a larger number for your settings. Experiment until you find what is right for you.