Sunday, May 29, 2011

Setting the keyboard layout with hal

Everytime when I start my X it has a US keyboard layout. After login I could change it with:

$ setxkbmap -model pc104 -layout de

to work with my german keyboard layout. But I have to do it everytime when I log in, which is not very professional. Even modifying the xorg.conf to load the german keyboard layout did not work:

$ cat /etc/X11/xorg.conf
Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "kbd"
        Option      "XkbModel"   "pc105"
        Option      "XkbLayout"  "de"
        Option      "XkbVariant" "nodeadkeys"

I always ended up with the us kayboard layout. But after investigating the /var/log/Xorg.0.log I found out that hal always forces X to load the us keyboard layout. So all I need to do is to configure hal to load the german keyboard layout. First I copied the keymap policy from the /usr/share directory to the /etc/hal directory:

# cp /usr/share/hal/fdi/policy/10osvendor/10-keymap.fdi /etc/hal/fdi/policy/

After that edited the keymap policy to load the german keyboard layout. I changed the line that holds the input.xkb.layout string:

# vi /etc/hal/fdi/policy/10-keymap.fdi
<!-- <merge key="input.xkb.layout" type="string">us</merge> -->
 <merge key="input.xkb.layout" type="string">de</merge>

Finally I needed to to restart the X server, eg:

# init 5
# init 4

That's all again. X with german keyboard layout.

No comments:

Post a Comment