First, run xev from a terminal. With the xev window focused, press each of the keys you want to get working, and make a note of the keycode it reports. Now, edit ~/.Xmodmap (or /etc/X11/Xmodmap for system-wide) so it looks something like this:
- ! Home keycode 178 = F20 ! Email keycode 236 = F21 ! Glass keycode 229 = F22 ! Run keycode 230 = F23 ! Mute keycode 160 = F24 ! Moon keycode 223 = F25 ! VDown keycode 174 = F26 ! VUp keycode 176 = F27 ! Play keycode 162 = F28 ! Stop keycode 164 = F29 ! Rew keycode 144 = F30 ! FF keycode 153 = F31 ! Caps Lock ! keycode 66 = F32 ! Win ! keycode 115 = F33 ! RWin ! keycode 116 = F34 ! Menu ! keycode 117 = F35
The !s mark comments, if you hadn't guessed. Now you need to make this file be run when X starts. The standard Xsession and Gnome sessions should load /etc/X11/Xmodmap without any further work, but if you want to use ~/.Xmodmap (neater, IMHO), add 'allow-user-modmap' to /etc/X11/Xsession.options (on its own line, no indent).
After restarting X, you need to add shortcuts for those keys to your window manager (or bbkeys or whatever). Under Gnome and KDE, use {g,k}control to do this. Open up the shortcut dialog, press Grab, then one of the extra keys. You can assign whatever action you like, but one of the most useful is 'Run shell script'.
Here are a couple of mine:
- #!/usr/bin/ruby # fade.rb - fade volume to $1, or mute/unmute if $1 not given
vol = aumix -q vol =~ /vol (^,?+)/ vol = $1.to_i aim = ARGV[0] if aim == NIL
- aim = 0
- aim = 70
- aim = vol + 5
- aim = vol - 5
- aim = aim.to_i
puts "#{vol} -> #{aim}" au = Proc.new { |i|
aumix -v #{i} sleep 0.002
if vol > aim
vol.downto(aim, &au)
vol.upto(aim, &au)
if xmms-shell -e status =~ /Playing:/
xmms-shell -e pause
xmms-shell -e play
Alexis Lee (LxS), 27.5.2002
