Set non-US keymap

I have got a machine with Swiss German keyboard layout, thus want a keymap that is appropriate.

But I just hate having my whole system in German, so I set all my locales in British English:

$ locale
LANG=en_GB.UTF-8
LC_CTYPE=”en_GB.UTF-8″
LC_NUMERIC=”en_GB.UTF-8″
LC_TIME=”en_GB.UTF-8″
LC_COLLATE=”en_GB.UTF-8″
LC_MONETARY=”en_GB.UTF-8″
LC_MESSAGES=”en_GB.UTF-8″
LC_PAPER=”en_GB.UTF-8″
LC_NAME=”en_GB.UTF-8″
LC_ADDRESS=”en_GB.UTF-8″
LC_TELEPHONE=”en_GB.UTF-8″
LC_MEASUREMENT=”en_GB.UTF-8″
LC_IDENTIFICATION=”en_GB.UTF-8″
LC_ALL=

Now to have my keymap set to Swiss German, I edit my rc.conf

LOCALE=”en_GB.UTF-8″
HARDWARECLOCK=”UTC”
TIMEZONE=”Europe/Zurich”
KEYMAP=”de_CH-latin1″

I chose one of the keymaps from

less /usr/share/X11/xkb/rules/xorg.lst

Alright, now we have got it working in a non-X (TTY) environment.

As expected, after firing up X, openbox still uses the US keymap.
Ok, you can always set the keymap manually with setxkbmap, but it gets annoying, since it is only valid for the current session.

setxkbmap -layout ch

Yeah, we could easily write a startup script that does exactly that before running your WM, e.g. adding the following at the end of the autostart.sh file of Openbox:

 (sleep 2 && setxkbmap -layout ch) &

But there are reported issues when resuming after suspending the machine.

So as to make this change really persistent, it is best to set your keymap globally and independently in the Xorg config files.
In my case, I just added an Option in /etc/X11/xorg.conf

Section “InputClass”
Identifier “evdev keyboard catchall”
MatchIsKeyboard “on”
MatchDevicePath “/dev/input/event*”
Driver “evdev”
Option “XkbLayout” “ch”
EndSection

(Before upgrading to Xorg 1.8, i.e. when HAL was still used, you were encouraged to edit /etc/hal/fdi/policy/10-keymap.fdi to set up your keybindings rather than doing this via X).

Advertisements

1 Comment

  1. Nice blog as for me. It would be great to read more concerning that theme. The only thing this blog needs is a few pics of any devices.

    John Stepman

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: