rebinding keys to functions

Roland Smith rsmith at
Mon Sep 14 22:40:41 UTC 2009

On Mon, Sep 14, 2009 at 11:06:20PM +0200, Polytropon wrote:
> 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.

Not all of them. My laptop is based on a quite modern cantiga (aka centrino2)
PM45 chipset (from 2008, according to Wikipedia). The function keys for
changing the creen brightness and sound volume work OK with FreeBSD, even
though xev doesn't see them. So that signal seems to go directly to the
hardware. Using the Fn key with the virtual numeric keypad works, and
generates normal keyboard events. I haven't tested the keys that can control a
media player, because I don't care about them.

> 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 just tested that today, and it worked OK in FreeBSD. Plug in the headphones,
they work and the speaker goes silent.

So I guess it is all about how the machine is put together. Even if a chipset
has certain functionality, it is up to the board manufacturer to connect

Writing a driver to detect if headphones are connected sounds much more
complicated to me than connecting a couple of switches! I mean, you'd have to
measure something like the impedance of the jack. Surely that is more
expensive than a simple switch?

[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url :

More information about the freebsd-questions mailing list