Install an additional keyboard layout on X11
The X11 project (otherwise known as X Windows) makes it easy to add another keyboard layout to your default configuration.
To get an idea of what’s possible to configure, view the X11 keyboard layout manual as follows:
# man xkeyboard-config
The following examples are from the Carpalx project, which like many other layouts, is already installed and available in X11:
The keyboard layouts can be configured for the:
— Session
— System
Session configuration
The session configuration is appropriate for evaluation of a keyboard layout.
From the command line, to show the current keyboard configuration, use setxkbmap:
# setxkbmap -print -verbose
The output may look something like this:
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+us+inet(evdev)
geometry: pc(pc105)
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+inet(evdev)" };
xkb_geometry { include "pc(pc105)" };
};#
The output shows that only the US Qwerty layout is being used.
Example 1 — add the Carpalx QGMLWB keyboard layout
To add another layout (eg Carpalx QGMLWB) to the current Qwerty, just state both layouts with a toggle key. A simple example is as follows:
# setxkbmap -layout us,us -variant ,carpalx-full -option "grp:alt_shift_toggle"
So in the above command, I’m setting the keyboard layout configuration as:
- 1st layout: US layout with the default variant (ie Qwerty).
- 2nd layout: US layout with the Carpalx QGMLWB variant.
- ALT-SHIFT keys to toggle between the layouts.
Use the setxkbmap print verbose command to view the new configuration:
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+us+us(carpalx-full):2+inet(evdev)+group(alt_shift_toggle)
geometry: pc(pc105)
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+us(carpalx-full):2+inet(evdev)+group(alt_shift_toggle)" };
xkb_geometry { include "pc(pc105)" };
};#
Example 2 — add the Carpalx QGMLWY keyboard layout
The Carpalx project also offers another layout (Carpalx QGMLWY) for X11 and this layout can be added with:
# setxkbmap -layout us,us -variant ,carpalx -option "grp:alt_shift_toggle"
However X11 offers many other options, including key redefinition, as follows:
# setxkbmap -layout us,us -variant ,carpalx -option "grp:alt_shift_toggle,caps:backspace"
So in the example above the configuration is:
- 1st layout: US layout with the default variant (ie Qwerty).
- 2nd layout: US layout with the Carpalx QGMLWY variant.
- ALT-SHIFT keys to toggle between the layouts.
- caps-lock key as a backspace key.
In this configuration, there will be two backspace keys: the original backspace key, plus the caps-lock key.
Now lets add some indication with the following command:
# setxkbmap -layout us,us -variant ,carpalx -option "grp:alt_shift_toggle,caps:backspace,grp_led:caps"
In the above example:
- 1st layout: US with the default variant (ie Qwerty).
- 2nd layout: US with the Carpalx QGMLWY variant.
- ALT-SHIFT keys to toggle between the layouts.
- caps-lock key as a backspace key.
- caps-lock LED to indicate that the 2nd layout is selected.
Reset the session configuration
As the configuration is for the session only, your changes will be lost on logout. However it may be more convenient to reset the configuration without logging out:
$ setxkbmap -layout us -option ""
System configuration
It may be desired to make the keyboard layout configuration permanent for the system.
There are actually two methods for permanent configuration:
- X11 configuration file
- X11 Graphical User Interface
i) X11 configuration file
Adding the configuration to the X11 setup is also simple by editing the /etc/X11/xorg.conf file (or equivalent X11 configuration file for your environment).
Add the following lines:
Section "InputClass"
Identifier "KeyboardDefaults"
# Driver "kbd"
# MatchIsKeyboard "on"
Option "XkbLayout" "us,us"
Option "XkbVariant" ",carpalx"
Option "XKbOptions" "grp:alt_shift_toggle,caps:backspace"
EndSection
ii) X11 Graphical User Interface configuration
Your X11 desktop environment may have a facility to edit the keyboard layout configuration. The following example is from the XFCE desktop environment.
Choose the keyboard option from the applications, then settings menus:
To change the configuration, uncheck the ‘Use system defaults’, then select add.
(Note — X11 does have Carpalx keyboard layouts defined and available, but not all desktop environments will have them available for selection from the menu.)
Here the Carpalx layout is available for selection.
There are many layout options available, but this time the toggle will be the ALT-CNTL keys.