Making volume keys work with KMix
I think that I am not the only one who bought one of this kind of keyboards and wish to have them working under Linux, Ubuntu do it without any modification as far I know, Kubuntu too, as I know there are extra tools to do it with a GUI, but I’ll teach you how that tools work
. Tested on Debian Lenny and Sid.
Requirements
- Have a keyboard with multimedia keys, as volume up & down
- Have
x11-utilspackage installed - Have super user access
- The K Environment
- KMix application installed
Tips
- This can work with anything that runs on the X server, but you need do extra editing, so have fun at that
We will use an application called xev that is into x11-utils, first of all, we need to know the keycode of the keys we want to configure, so we do the following thing.
$ xev
Then a window showing many text will appear, however, we click on JUST the keys we want to configure, in mine case it show off it when I clicked that keys (volume up&down). The keycodes are in bold.
The increase volume button
KeyPress event, serial 31, synthetic NO, window 0×2a00001,
root 0×8a, subw 0×0, time 1517838800, (-479,599), root:(207,626),
state 0×10, keycode 176 (keysym 0×0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: FalseKeyRelease event, serial 31, synthetic NO, window 0×2a00001,
root 0×8a, subw 0×0, time 1517838951, (-479,599), root:(207,626),
state 0×10, keycode 176 (keysym 0×0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: FalseKeyPress event, serial 31, synthetic NO, window 0×2a00001,
The decrease volume button
root 0×8a, subw 0×0, time 1517844324, (252,33), root:(938,60),
state 0×10, keycode 174 (keysym 0×0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 31, synthetic NO, window 0×2a00001,
root 0×8a, subw 0×0, time 1517844482, (252,33), root:(938,60),
state 0×10, keycode 174 (keysym 0×0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
Then we create ~/.kde/Autostart/keycodes and we put in this (editing to match with your keycodes).
#!/bin/sh
#file to map special keys.
#File location: ~/.kde/Autostart
#File Name:keycodesxmodmap -e ‘keycode 174=F21′ #voldown
xmodmap -e ‘keycode 176=F22′ #volup#Abrimos kmix y dejamos que xbindkeys sirva
kmix#Se abre xbindkeys para enlazar las teclas de acceso rapido con los programas
xbindkeys
Then we edit ~/.xbindkeysrc (if it doesn’t exists, we need to create it) and we add the following lines
#Volume decrease
“dcop kmix Mixer0 decreaseVolume 0″
F21#Volume increase
“dcop kmix Mixer0 increaseVolume 0″
F22

Arknold! Works perfectly.
Heres the setup for Amarok:
“dcop amarok player playPause”
F24
“dcop amarok player next”
F25
“dcop amarok player prev”
F26
yey, okay… answered a million years after xd
dcop is deprecated