Multimedia keyboards: uhidd/xbindkeys/xmodmap

Table of Contents

uhidd: The driver
xbindkeys: Create hotkeys
xmodmap: Remap the keys

xmodmap: Remap the keys

by ross at 06:40:06 on December 4, 2012

Install

# cd /usr/ports/x11/xmodmap
# make install clean
# cd /usr/ports/x11/xev
# make install clean
# rehash

You need xev to get the code of keys.

Enable

> cd
> xmodmap -pke > .xmodmap

Add to .xinitrc or your DE startup file:

xmodmap ~/.xmodmap &

Configure

Run xev and press the key you want to remap. Watch for ”keycode NN” in output. NN is the code you need.

In order to remap the key edit .xmodmap file, find the line of that key and assign new value:

keycode 135 = p

Here I assign letter “p” to a key with keycode 135 (my remote sends it when I press Play/Pause key). I use “p” because it is xbmc's hotkey for play/pause.

You are not limited to letters. For example, this is how I assign [ and ] keys (Prev/Next in xbmc):

keycode 184 = bracketright
keycode 189 = bracketleft

Where did I get the names of these keys? Here:

...
#define XK_bracketleft                   0x005b  /* U+005B LEFT SQUARE BRACKET */
#define XK_backslash                     0x005c  /* U+005C REVERSE SOLIDUS */
#define XK_bracketright                  0x005d  /* U+005D RIGHT SQUARE BRACKET */
#define XK_asciicircum                   0x005e  /* U+005E CIRCUMFLEX ACCENT */
#define XK_underscore                    0x005f  /* U+005F LOW LINE */
#define XK_grave                         0x0060  /* U+0060 GRAVE ACCENT */
#define XK_quoteleft                     0x0060  /* deprecated */
...

This is /usr/local/include/X11/keysymdef.h (installed by x11/xproto port).

When done editing your .xmodmap run:

> xmodmap ~/.xmodmap

 

Comments