HAL + Xorg X server : Using HAL to set hardware specific configurations for Xorg Xserver

The Xorg X Server can now rely on HAL to get information about the hardware the machine is running. This allows the X Server to auto-configure most of its components such as keyboard / mouse / screen / graphic adapter. But there is still room for tweaking it if needed.

This post explains how to configure extra properties for a keyboard at the HAL level, so that X Server will correctly auto-configure it for you.

How to see what HAL knows about your machine

The command hal-device will list what HAL knows about your machine. Here is the output pertaining to the keyboard I’m using :

$ hal-device
[...]
44: udi = '/org/freedesktop/Hal/devices/usb_device_46d_c315_noserial_if0_logicaldev_input'
  input.product = 'Logitech Logitech USB Keyboard'  (string)
  info.addons.singleton = { 'hald-addon-input' } (string list)
  input.originating_device = '/org/freedesktop/Hal/devices/usb_device_46d_c315_noserial_if0'  (string)
  input.xkb.rules = 'base'  (string)
  input.xkb.model = 'evdev'  (string)
  input.xkb.layout = 'us'  (string)
  input.xkb.variant = ''  (string)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1a.2/usb8/8-1/8-1:1.0/input/input2/event2'  (string)
  info.parent = '/org/freedesktop/Hal/devices/usb_device_46d_c315_noserial_if0'  (string)
  info.category = 'input'  (string)
  info.capabilities = { 'input', 'input.keyboard', 'input.keypad', 'input.keys', 'button' } (string list)
  info.subsystem = 'input'  (string)
  info.product = 'Logitech Logitech USB Keyboard'  (string)
  linux.device_file = '/dev/input/event2'  (string)
  info.udi = '/org/freedesktop/Hal/devices/usb_device_46d_c315_noserial_if0_logicaldev_input'  (string)
  input.x11_options.XkbOptions = 'altwin:super_win'  (string)
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'input'  (string)
  input.device = '/dev/input/event2'  (string)
[...]

We can see that my USB keyboard has been detected as a “Logitech Logitech USB Keyboard” with a “us” layout (QWERTY keyboard).

The Xorg X Server will be able to use this information to configure the keyboard map for you accordingly.

If you need to pass extra information (for example, you might need the X Server to set up the “international” variant for the US keyboard, in order to be able to type in accentuated and other special characters), you’ll need to edit the “policy file” for the keyboard.

Tweaking HAL information

Additional information can be added to the HAL if needed, by editing policy files. Those files are located in /etc/hal/fdi/policy/.

For the example of the US international keyboard, I simply created the following file :

?Download keyboard.fdi
<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
	<device>
	<match key="info.capabilities" contains="input.keyboard">
		<match key="info.product" contains="Logitech Logitech USB Keyboard">
			<merge key="input.x11_driver" type="string">evdev</merge>
			<merge key="input.x11_options.XkbLayout" type="string">us</merge>
			<merge key="input.x11_options.XkbVariant" type="string">intl</merge>
		</match>
	</match>
	</device>
</deviceinfo>

This snippet adds the keys input.x11_options.XkbLayout=us , input.x11_options.XkbVariant=intl and input.x11_driver=evdev to the Logitech keyboard.

The Xorg X Server will pick up those entries and configure the keyboard accordingly.

One thought on “HAL + Xorg X server : Using HAL to set hardware specific configurations for Xorg Xserver”

Leave a Reply

Your email address will not be published. Required fields are marked *