Thursday, April 14, 2011

Getting multimedia keys to work on Unix-like systems

Notes:
1. I tested this with Xorg, though it should flawlessly work with Xfree86 too.
2. Thanks 'macrobat' on #debian (irc.freenode.net) for help.

First of all setup your ~/.Xmodmap based on following links:
http://en.gentoo-wiki.com/wiki/Multimedia_Keys#Setting_up_xmodmap
http://wiki.archlinux.org/index.php/Extra_Keyboard_Keys_in_Xorg#Step_1:_Create_the_xmodmap_file

Now you need to bind keys using xbindkeys. Install 'xbindkeys', if it's not already installed. Now generate ~/.xbindkeysrc using:

xbindkeys --defaults > /home/amber/.xbindkeysrc

Or else, simply start with a new blank file ~/.xbindkeysrc in your text editor. Then edit the code snippet below to match your system and put it in ~/.xbindkeysrc. As you had probably guessed yourself, you can bind other actions/commands specified in your .Xmodmap here.
# mute
"amixer sset Master toggle"
  m:0x0 + c:160
  XF86AudioMute 
# vol down
"amixer set Master 2dB- unmute"
  m:0x0 + c:174
  XF86AudioLowerVolume
# vol up
"amixer set Master 2dB+ unmute"
  m:0x0 + c:176
  XF86AudioRaiseVolume
Note: The lines indented in the code above may be different on your system. To find them, use:
xbindkeys --key
Now, put these line to your .xinitrc:
xmodmap ~/.Xmodmap
xbindkeys -f ~/.xbindkeysrc
Then restart X.

No comments:

Post a Comment