How do I set a custom keyboard shortcut to control volume?

Solution 1:

@dobey's solution works if you want to have only one keyboard shortcut for increasing / decreasing the volume.

If instead you want to have multiple key bindings controlling the volume (like to keep the default volume buttons on your laptop working, while adding additional keyboard shortcuts to use when you connect an external keyboard that does not have volume controls), then:

  1. Go to System Settings → Keyboard → Shortcuts → Custom Shortcuts.

  2. Click + to add a new keyboard shortcut. Set the "Name" to Volume up, "Command" to

    amixer -D pulse sset Master 5%+ and click Apply.

  3. Click Disabled next to your new key and choose the desired binding on your keyboard.

  4. Add another shortcut with name Volume down and command

    amixer -D pulse sset Master 5%-

Steps GIF

Solution 2:

Open System Settings, go to Keyboard, then the Shortcuts tab, and finally choose Sound and Media in the list on the left. You can then choose the Volume related items in the list on the right side, and select which keybinding to use.

(Reverse usage of left and right here, for RTL languages.)

Solution 3:

Usually, this command works just fine as a command for lowering the volume (Ubuntu 16.04):

amixer -q -D pulse sset Master 5%- 

On Ubuntu 18.XX (Gnome) escape the % symbol:

amixer -q -D pulse sset Master 5%%-

Worked for me!