The Slackware OS was successfully upgraded on Fri Oct 3 14:39:01 UTC 2014
The Wiki was successfully upgraded on Fri Oct 3 15:42:57 UTC 2014

Welcome to the Slackware Documentation Project

Setting a Keyboard Layout

Setting a keyboard layout is a necessary step if you do not want the default us layout. Furthermore, some people quite often need to switch between layouts. Below you'll find ways of setting / changing the keyboard layout both in the console and in X.

Keyboard in the Console

Keyboard layout is first set during the installation process where you're asked to choose a relevant keyboard map. This setting only applies to the console before you start the X server (GUI).

It can be changed in /etc/rc.d/rc.keymap:

#!/bin/sh
# Load the keyboard map.  More maps are in /usr/share/kbd/keymaps.
if [ -x /usr/bin/loadkeys ]; then
 /usr/bin/loadkeys uk.map
fi

As you can see above, I use the UK layout. More keyboard layouts can be found in the directory mentioned above.

Please note that if you decide not to change the default layout (US) during the installation process, the file /etc/rc.d/rc.keymap will not be created. If, at a later stage, you need to change it, you will need to create that file, copy the above code and choose one of the keymaps available in the /usr/share/kdb/keymaps/ directory.

Keyboard Layout in X

Setting up a keyboard layout for X can be done in 2 ways: system-wide (regardless of your desktop environment or user) or on a desktop environment / window manager level.

Setting the Layout System-wide

Slackware 13.0 and 13.1

In Slackware 13.0 and 13.1 hal was responsible for keyboard mapping:

Copy the relevant .fdi file to /etc/hal/fdi/policy/:

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

Edit the file:

vim /etc/hal/fdi/policy/10.keymap.fdi

Replacing us with a keymap of your choice (in my case it is gb):

<merge key=“input.xkb.layout” type=“string”>us</merge>
<merge key=“input.xkb.layout” type=“string”>gb</merge>

Slackware 13.37 and 14

From Slackware 13.37 on, udev has taken over keyboard mapping functions and the procedure has changed as well:

cp /usr/share/X11/xorg.conf.d/90-keyboard-layout.conf /etc/X11/xorg.conf.d/

Edit the 90-keyboard-layout.conf file specifying the layout (eg. gb):

vim /etc/X11/xorg.conf.d/90-keyboard-layout.conf
Section "InputClass"
        Identifier "keyboard-all"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "XkbLayout" "gb"
        #Option "XkbVariant" ""
        Option "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection

You also need to restart X for the change to take effect.

Setting the Layout in Particular Desktop Environments / Window Managers

Some environments by default include GUI tools to set the keyboard layout while others require tweaking the startup files and a manual use of the setxkbmap command. You can use this command at any time if you want to change the keyboard layout in X. You might need to restart certain applications for the changes to take effect.

This, for example, would switch your keyboard layout to Polish:

setxkbmap pl

Below are some ways of changing keyboard layouts within particular desktop environments or window managers.

KDE

Xfce

Fluxbox

i3

Sources


In Other Languages
Translations of this page?:
QR Code
QR Code howtos:window_managers:keyboard_layout (generated for current page)