Log in

Debian/X.org notes - Howto Input-hotplug? - Brice Goglin's Blog

Jan. 24th, 2009

22:00 - Debian/X.org notes - Howto Input-hotplug?

Previous Entry Share Next Entry

I have been wondering for a while how to get X.org "input-hotplug" to work, but I never actually tried before today. It is actually fairly easy, once you know what to do.


First, make sure you have the evdev X driver installed (xserver-xorg-input-evdev). You might want to use X packages from experimental since things are much more recent than in Lenny or Sid these days, and upstream improved input management in the meantime. Then, if you are not running a pre-packaged kernel, check the the evdev driver is enabled and loaded in your kernel (CONFIG_INPUT_EVDEV).

Telling hal what to do with input devices

Now, you need to tell hal how to configure your input devices. Actually, you do not have much to do since latest xserver-xorg-input-evdev packages bring what you need. hal reads all fdi files under /usr/share/hal/fdi/policy to find out how devices should be configured. If you run lshal and look for input, you should see that the evdev is planned to drive your input devices.

However, if you look at keyboard devices in lshal (look for input.keys), you will see that the US layout is used. To switch to another layout, you can add some overriding rules as a new *.fdi file in /etc/hal/fdi/policy/. For instance, to get French layout:

<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
    <match key="info.capabilities" contains="input.keys">
      <-- Enforce XkbLayout=fr and XkbVariant empty -->
      <merge key="input.xkb.layout" type="string">fr</merge>
      <merge key="input.xkb.variant" type="string" />

Thanks to this, you can enforce XkbLayout, XkbVariant and friends as usual in /etc/X11/xorg.conf. Don't forget to restart hal after modifying some fdi files. Then run lshal, and look for Xkb, you should find your setup there. Note that you can add some matching rules to configure some devices with different setups if needed. Just need to read the output of lshal and find something like a hardware identifier to match on.

You can find some documentation about these rules by looking at the existing fdi files in /usr/share/hal/fdi/policy/20thirdparty/, and in the upstream x11-input.fdi (note that input.xkb.foo is the actual recommended syntax instead of input.x11_options.XkbFoo).


If you have a touchpad and want to use the synaptics driver, installing the xserver-xorg-input-synaptics will bring another fdi file. /usr/share/hal/fdi/policy/20thirdparty/11-x11-synaptics.fdi matches input.touchpad in the device capabilities in hal. Now the synaptics driver will be automagically loaded for your touchpad (instead of evdev for regular mice). Again, you can override this rule in /etc/hal/fdi/policy/ and you can add many configuration options for synaptics as well. See /usr/share/hal/fdi/policy/20thirdparty/11-x11-synaptics.fdi to get an example.

Fortunately, you will not have to manually take care of the above /etc/hal/fdi/policy/ file for ever. The plan is to have hal look at the Debian console configuration and get at least the keyboard layout from there automatically.

Telling the Xserver to talk to hal

Now, you need to tell the Xserver to use what hal wants. Basically, you want to remove everything about keyboard, mouse and other input devices from your xorg.conf. Just drop all InputDevice sections and all references to them within other sections. With recent Xserver versions, options AllowEmptyInput and AutoAddDevices are enabled by default (otherwise, you might have to add them in the ServerFlags section).

Ignoring a device

If you do not want Xorg to use one of your input device, in the past you would just have not talked about it in xorg.conf. Now, hal notifies the server of all devices, and all of them are enabled by default. To disable it, you can use something like:

  <match key="info.product" contains="myname">
    <remove key="input.x11_driver"/>

For more information

For more documentation, you want to read Peter Hutterer's blog, especially this post and this one.

By the way, if you don't want this input-hotplug thing and you want to run a recent Xserver anyway, you should set AllowEmptyInput and AutoAddDevices to off in the ServerFlags section.

Update: Fixed the way to manage fdi files, fixed the syntax of input.xkb.foo rules, added a paragraph about synaptics, added a way to ignore a device, and organized things in sections. Thanks to everybody's comments.

(Permanent link