rebinding keys to functions

Polytropon freebsd at
Mon Sep 14 21:06:23 UTC 2009

On Mon, 14 Sep 2009 14:34:29 -0400, Robert Huff <roberthuff at> wrote:
> Roland Smith writes:
> >  > My laptop has a bunch of volume-up/down/mute internet/mail/etc 
> >  > keys.  How do I map each of them to run a specific shell
> >  > command when pressed? 
> >  
> >  That depends on a couple of things (assuming you're running the X
> >  window system, I don't know if it is even possible on the
> >  console).
> >  
> >  First you have to make sure that you actually can see the key
> >  signals. In X you can test that with xev(1).
> 	If this is what I think it is, he probably can't.

For most laptop keyboards, there was (as already explained) a
specific system that handled Fn+PFx outside the OS so it worked
always. Even my old Toshiba T1600 can do that.

"Modern" laptops do it differently: Fn+PFx key combinations
have to be picked up by a specific driver that "listens" to
stange and custom keycodes outside the standard range, and then
communicate the selected purpose to the OS in order to perform
the action, e. g. raise the volume.

Even worse, "modern" laptops have replaced the simple switches
in the earophone sockets. In the past, there was a mechanical
switch that switched off the internal speakers when you inserted
a 3,5mm jack. Today, a proprietary driver has to detect if a
jack is inserted, and then switch of the speakers and then
switch on the output of the socket.

> 	I have a Logitech iTouch keyboard; it has eighteen buttons and
> two dials.  None of them register under xev.

The Apple USB keyboard is something similar. Allthough most keys
show up in xev, F13 and the four additional four keys on the right
(volume, eject) don't show up. I've been advised that it is quite
possible to look into the ukbd driver subsystem, add some
debugging and log what happens when those keys are pressed; they
can then be assigned a specific number which afterwards resolves
tp a certain key symbol. Would be great if they worked...

But life can be so easy when you've got good hardware, such as the
Sun USB type 6 keyboard. The 2x5 and 1 keys on the left as well
as the four keys on the top right show up in xev. I'm using a
xmodmap file ~/.xmodmaprc to map them to a certain (arbitrary)
key name, like

	! Stop
	keycode 145 = F14
	! Meta links
	keycode 115 = Meta_L
	! Meta rechte
	keycode 116 = Meta_R
	! Compose
	keycode 117 = Multi_key
	add mod4 = Multi_key

After that, I can use the config tool of WindowMaker to connect
those key names to actions, like rolling up or hiding windows,
running specific programs or performing other actions (e. g.
moon key = log off, Ctrl+Alt+Moon = shutdown now; help = xlock).

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list