vendredi 20 février 2009

Setup dvorak on Debian with Xorg without HAL / evdev bugs

Dvorak setup used to be easy to set up :

$ dpkg-reconfigure -phigh console-data
$ dpkg-reconfigure -phigh xserver-xorg

Nothing much fancier if you were used to light systems and spent most of your time in your terminals / editor.

All the general Xorg conf was located in /etc/X11/xorg.conf :

Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc104"
Option "XkbLayout" "dvorak"
EndSection


One could have setup some personal settings in .xinitrc :

$ xmodmap ~/.myxmodmaprc

(CapsLock as additional Ctrl key, and Compose key on Ctrl_L for instance)

Console setup is just as easy as before (console-setup package is just fine) but X needs a little attention.


Obfuscation



Nowadays, Xorg uses HAL/evdev to auto-magically configure the keyboard layout. However the default policy is to use a "us" layout on a buggy "evdev" model (on Linux) ...

A proper setup can be :

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

2. and edit accordingly :


<?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">xorg</merge>

<merge key="input.xkb.model" type="string">keyboard</merge>
<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
string="Linux">
<merge key="input.xkb.model" type="string">pc105</merge>
</match>
<!-- force dvorak -->
<merge key="input.xkb.layout" type="string">dvorak</merge>
<merge key="input.xkb.variant" type="string" />
</match>
</device>
</deviceinfo>



3. restart HAL and X

Testing


You can test your settings :
1. stop GDM/KDM/...
2. login as user in console mode
3. edit ~/.xinitrc :

xmodmap ~/.xmodmaprc.foo &
xterm &
yourwindowmanager

4. run $ startx


Gnome and related



Gnome uses an g-app to set up various keyboard options : gnome-keyboard-properties which requires gnome-settings-daemon which requires DBus launched which is usually triggered by GDM ...
Anyway, once your basic X config is OK, you can try g-k-p and set up your keyboard. "Generic/evdev" is meant to be used accordingly with the default HAL fdi ; I chose "Generic/pc104".

Related X package : xserver-xorg-input-evdev