Table of Contents

X Keymapping

On occasions I found that after emerge -uDN @world that my keymappings under X had gone awry and reverted to US, despite no changes to my /etc/X11/xorg.conf. Thing were fine under a TTY, but not under X.

UPDATE This page is now pretty much redundant, HAL has been purged from the Gentoo Portage tree and udev is used (although as of writing it has been forked).

Why?

These problems arise as a consequence of switching between HAL and udev for hardware detection. I first encountered the problem when I upgraded to a version of Xorg >1.5 as input devices such as keyboard, mouse and touchpads are now controled by HAL and http://xorg.freedesktop.org/evdev. However, HAL is now effectively dead (unmaintained, no updates) and as such is marked for removal from Gentoo, so now control is now under udev/http://xorg.freedesktop.org/evdev

Fixing keyboard maps under HAL

As control is now under sys-apps/hal (HAL) via http://xorg.freedesktop.org/evdev the configurations now reside in /usr/share/hal/fdi/policy/. You could edit these but you would have to be careful when updating packages and ensure you do not wipe them out. The alternative is to use a local directory structure and place the changes under /etc/hal/fdi/policy/.

For the keyboard map you want to have the following file /etc/hal/fdi/policy/10-x11-input.fdi reflect your heyboards key map.

<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
<device>
    <!-- Mouse configuration -->
    <match key="info.capabilities" contains="input.mouse">
      <merge key="input.x11_driver" type="string">evdev</merge>
    </match>

    <!-- Keyboard configuration -->
    <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.model" type="string">evdev</merge>
      <merge key="input.x11_driver" type="string">evdev</merge>
      <merge key="input.xkb.layout" type="string">gb</merge>
      <append key="input.xkb.options" type="strlist">compose:menu</append>
    </match>
  </device>
</deviceinfo>

Synaptics TouchPad

If you happen to have a Synaptics Touch Pad (common on many laptops) you will need the file /etc/hal/fdi/policy/11-x11-synaptics.fdi

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
  <device>
    <match key="info.capabilities" contains="input.touchpad">
      <match key="info.product" contains="Synaptics TouchPad">
        <merge key="input.x11_driver" type="string">synaptics</merge>
   <merge key="input.x11_options.SHMConfig" type="string">on</merge>
   <!-- Tapping -->
        <merge key="input.x11_options.TapButton1" type="string">1</merge>
        <merge key="input.x11_options.TapButton2" type="string">2</merge>
        <merge key="input.x11_options.TapButton3" type="string">3</merge>
   <!-- Scrolling up/down -->
        <merge key="input.x11_options.VertEdgeScroll" type="string">1</merge>
        <merge key="input.x11_options.HorizEdgeScroll" type="string">1</merge>
        <!-- Corner clicks -->
        <merge key="input.x11_options.RBCornerButton" type="string">2</merge>
        <merge key="input.x11_options.RTCornerButton" type="string">3</merge>
      </match>
    </match>
  </device>
</deviceinfo> 

Fixing keyboard maps under udev

This is the most likely situation you will be in (after all what is the point in installing and configuring dead packages?). Under udev and evdev devices are semi-automatically detected, but a /etc/X11/xorg.conf file is required. Within this file you need to define an InputClass for your keyboard and under this you specify the XkbLayout as shown

Section "InputClass"
   Identifier	     "Keyboard0"
   MatchIsKeyboard   "True"
   Driver	     "evdev"
   Option	     "XkbModel" "evdev"
   Option	     "XkbLayout" "gb"
EndSection 

Synaptics TouchPad

If you happen to have a Synaptics Touch Pad (common on many laptops) you will need an InputClass for this too…

Section "InputClass"
	Identifier	"Synaptics"
	MatchIsTouchpad "on"
	MatchDevicePath "/dev/input/event*"
	Driver 		"synaptics"
EndSection

gentoo linux howto X