For configuring the keyboard on Linux the tool
setxkbmap can be used. Files with information about this tool can be found in
All keyboard layouts and options are listed in
Change Keyboard Layout
For example, change layout to Swiss German.
Set Multiple Keyboard Layouts
For example, Swiss German and German.
The first layout in the list will be activated by default.
Define Shortcut For Switching Between Keyboard Layouts
For example, Alt-Shift.
setxkbmap -option 'grp:lalt_lshift_toggle'
Swap “Caps Lock” and “Ctrl” Keys
setxkbmap -option 'ctrl:swapcaps'
Note: the light on the Caps-Lock key might still be activated by the old Caps-Lock key (which now has the Ctrl function).
- The settings made by
setxkbmapdon’t persists across logins.
- Putting the
setxkbmapcommands in the
~/.bash_profileto make the settings persistent might cause an X error (cannot open display “default display”)
- Another option to make the settings persistent would be to put the commands in
~/.xinitrc, or in another syntax in
/etc/X11/xorg.conf.d/00-keyboard.conf. However, this doesn’t work in a consistent and reliable way, because different desktop environments (e.g. Xfce, KDE, GNOME) read these files in different ways on startup.
- A workaround is to put the
setxkbmapin a function in
~/.bashrcand to call this function manually.