X doesn't follow my HAL configuration wrt keyboard layout

Hi,

I’m having a hard time configuring my keyboard exactly how I want it. My system is a laptop, either used stand-alone (internal keyboard) or on a docking station with a USB keyboard attached. Both are AZERTY and detected as such by default, they get configured with an average layout.

I want to use another layout, namely “fr-latin9” as found in /usr/share/X11/xkb/rules/base. [From now on I’ll use the docking-station situation as a case study.] So, I add a section to /etc/hal/fdi/policy/20thirdparty/11-keymap.fdi which now reads:

<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
  <device>
    <match key="info.capabilities" contains="input.keymap">
      <append key="info.callouts.add" type="strlist">hal-setup-keymap</append>
    </match>

    <match key="info.capabilities" contains="input.keys">
      <merge key="input.xkb.rules" type="string">base</merge>
      <merge key="input.xkb.model" type="string">evdev</merge>
      <merge key="input.xkb.layout" type="string"></merge>
      <merge key="input.xkb.variant" type="string"></merge>
      <merge key="input.xkb.options" type="string"></merge>
    </match>

    <match key="info.product" contains="HID 046a:0023">
      <match key="info.capabilities" contains="input.keyboard">
        <merge key="input.xkb.layout" type="string">fr-latin9</merge>
        <merge key="input.xkb.options" type="string">compose:menu,lv3:ralt_switch,altwin:meta_win,caps:internal,nbsp:level2</merge>
      </match>
    </match>

  </device>
</deviceinfo>

The 's are correct to refer to the USB keyboard. Here’s the relevant lshal output:

udi = '/org/freedesktop/Hal/devices/usb_device_46a_23_noserial_if0_logicaldev_input'
  info.addons.singleton = {'hald-addon-input'} (string list)
  info.capabilities = {'input', 'input.keyboard', 'input.keypad', 'input.keys', 'button'} (string list)
  info.category = 'input'  (string)
  info.parent = '/org/freedesktop/Hal/devices/usb_device_46a_23_noserial_if0'  (string)
  info.product = 'HID 046a:0023'  (string)
  info.subsystem = 'input'  (string)
  info.udi = '/org/freedesktop/Hal/devices/usb_device_46a_23_noserial_if0_logicaldev_input'  (string)
  input.device = '/dev/input/event2'  (string)
  input.originating_device = '/org/freedesktop/Hal/devices/usb_device_46a_23_noserial_if0'  (string)
  input.product = 'HID 046a:0023'  (string)
  input.x11_driver = 'evdev'  (string)
  input.xkb.layout = 'fr-latin9'  (string)
  input.xkb.model = 'evdev'  (string)
  input.xkb.options = 'compose:menu,lv3:ralt_switch,altwin:meta_win,caps:internal,nbsp:level2'  (string)
  input.xkb.rules = 'base'  (string)
  input.xkb.variant = ''  (string)
  linux.device_file = '/dev/input/event2'  (string)
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'input'  (string)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2.3/1-2.3:1.0/input/input2/event2'  (string)

Now for the relevant part of /var/log/Xorg.0.log:

(II) config/hal: Adding input device HID 046a:0023
(**) HID 046a:0023: always reports core events
(**) HID 046a:0023: Device: "/dev/input/event2"
(II) HID 046a:0023: Found keys
(II) HID 046a:0023: Configuring as keyboard
(II) XINPUT: Adding extended input device "HID 046a:0023" (type: KEYBOARD)
(**) Option "xkb_rules" "evdev"
(**) Option "xkb_model" "evdev"
(**) Option "xkb_layout" "fr-latin9"
(**) Option "xkb_options" "compose:menu,lv3:ralt_switch,altwin:meta_win,caps:internal,nbsp:level2"
(II) XKB: reuse xkmfile /var/lib/xkb/compiled/server-AEAEDB693AFCEE21E4448DEE6BD5A4D075230E5E.xkm

Then at two places there’s a block of messages about reopening each input device:

(II) HID 046a:0023: Device reopened after 1 attempts.

This all sounds good BUT I don’t get the desired layout (fr-latin9 should give specific AltGr combinations, and the options should map e.g. Menu to Compose and the Win keys to Meta).

Now, if I unplug the keyboard and plug it back, I get the wanted layout! (But I’m not going to do this each time I boot on the docking station (or what’s the use of the station?), and I can’t do that with the internal keyboard rotfl! which suffers the same problem!) This procedure changes only the last line of lshal output:

  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2.3/1-2.3:1.0/input/input13/event2'  (string)

and produces these messages in /var/log/Xorg.0.log:

(II) config/hal: removing device HID 046a:0023
(II) HID 046a:0023: Close
(II) UnloadModule: "evdev"
(II) config/hal: Adding input device HID 046a:0023
(**) HID 046a:0023: always reports core events
(**) HID 046a:0023: Device: "/dev/input/event2"
(II) HID 046a:0023: Found keys
(II) HID 046a:0023: Configuring as keyboard
(II) XINPUT: Adding extended input device "HID 046a:0023" (type: KEYBOARD)
(**) Option "xkb_rules" "evdev"
(**) Option "xkb_model" "evdev"
(**) Option "xkb_layout" "fr-latin9"
(**) Option "xkb_options" "compose:menu,lv3:ralt_switch,altwin:meta_win,caps:internal,nbsp:level2"
(II) XKB: reuse xkmfile /var/lib/xkb/compiled/server-AEAEDB693AFCEE21E4448DEE6BD5A4D075230E5E.xkm

and these in /var/log/messages:

Jan 19 14:55:55 coulomb kernel: [19898.534134] /usr/src/packages/BUILD/kernel-desktop-2.6.31.8/linux-2.6.31/drivers/hid/usbhid/hid-core.c: can't reset device, 0000:00:1a.7-2.3/input0, status -71
Jan 19 14:55:55 coulomb kernel: [19898.534219] usb 1-2: clear tt 3 (0030) error -32
Jan 19 14:55:55 coulomb kernel: [19898.542492] /usr/src/packages/BUILD/kernel-desktop-2.6.31.8/linux-2.6.31/drivers/hid/usbhid/hid-core.c: can't reset device, 0000:00:1a.7-2.3/input0, status -71
Jan 19 14:55:55 coulomb kernel: [19898.542696] usb 1-2: clear tt 3 (0030) error -32
Jan 19 14:55:55 coulomb kernel: [19898.689338] usb 1-2.3: USB disconnect, address 3
Jan 19 14:55:55 coulomb kernel: [19898.689402] /usr/src/packages/BUILD/kernel-desktop-2.6.31.8/linux-2.6.31/drivers/hid/usbhid/hid-core.c: can't reset device, 0000:00:1a.7-2.3/input0, status -108
Jan 19 14:56:05 coulomb kernel: [19908.071220] usb 1-2.3: new low speed USB device using ehci_hcd and address 5
Jan 19 14:56:05 coulomb kernel: [19908.151213] usb 1-2.3: New USB device found, idVendor=046a, idProduct=0023
Jan 19 14:56:05 coulomb kernel: [19908.151235] usb 1-2.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jan 19 14:56:05 coulomb kernel: [19908.151494] usb 1-2.3: configuration #1 chosen from 1 choice
Jan 19 14:56:05 coulomb kernel: [19908.156430] input: HID 046a:0023 as /devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2.3/1-2.3:1.0/input/input13
Jan 19 14:56:05 coulomb kernel: [19908.156691] cherry 0003:046A:0023.0003: input,hidraw0: USB HID v1.11 Keyboard [HID 046a:0023] on usb-0000:00:1a.7-2.3/input0

Any suggestion?

Thanks.

Are you getting the desired effect initially and then, not getting it after some time?
It looks like there is a “USB disconnect” happening (from the /var/log/messages) and then, getting re-connected. Was it behaving correctly before this event?

From my experience any reference in xorg.conf to the hardware you are trying to configure through HAL will nullify your HAL configuration.

Yes, this is true. If you have xorg.conf, you need to delete or move it out of /etc/X11.

Indeed, delete xorg.conf, and, if on KDE4, run systemsettings, Country and Region, set the proper values for the keyboards there. Should make it possible to even change between them.

No. The exerpt from /var/log/messages corresponds to the explained procedure: unplugging and plugging back the keyboard. And this procedure precisely make the config work.

In reply to #3-5:
Yes, I forgot to mention that my xorg.conf has no settings regarding input devices, of course. (But you give me an idea: I wanted to conform to the standard procedure of configuring HAL rather than X, maybe I should give up and try to enforce my config through xorg.conf. I cannot remember if I already tried this.)

I found the culprit: gdm.*It has a tiny option at the bottom to set keyboard layout, thus overriding X settings.

I hate that kind of behaviour.*It could at least use the X setting as a default.

Switched to slim (from the contrib repo).*It’s nice!