1056N/AThis document describes how to configure Xorg XKB from a user's point of view.
1056N/AIt covers basic configuration syntax and gives also a few examples.
1056N/AThis version covers Xorg server versions 1.8 and later, used with the data
1056N/Afiles from the xkeyboard-config project.
1056N/A━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1056N/A Even More Advanced Configuration
1056N/AThe XKB configuration is decomposed into a number of components. Selecting
1056N/Aproper parts and combining them back you can achieve most of the configurations
1056N/Ayou might need. Unless you have a completely atypical keyboard you really don't
1056N/Aneed to touch any of the xkb configuration files.
1056N/ASome desktop environments now provide integrated graphical configuration tools
1056N/Afor setting XKB configuration as part of your desktop session. The instructions
1056N/Ain this document are provided for those without such support, those who need to
1056N/Aconfigure XKB before the session startup (such as at the login screen), or
1056N/Athose who need to perform more advanced configuration than those tools provide.
1056N/AThe easiest and the most natural way to specify a keyboard mapping is to use
1056N/Athe rules component. As its name suggests it describes a number of general
1056N/Arules to combine all bits and pieces into a valid and useful keyboard mapping.
1056N/AAll you need to do is to select a suitable rules file and then to feed it with
1056N/Aa few parameters that will adjust the keyboard behaviour to fulfill your needs.
1056N/AXkbRules files of rules to be used for keyboard mapping composition
1056N/AXkbModel name of the model of your keyboard type
1056N/AXkbLayout layout(s) you intend to use
1056N/AXkbVariant variant(s) of the layout you intend to use
1056N/AXkbOptions extra xkb configuration options
1056N/AThe rules file used depends on your system. The rules files commonly used with
1056N/AXorg are provided by the xkeyboard-config project. On Linux systems, the evdev
1056N/Arules are most commonly used, on other systems the base rules are used. Some
1056N/Aadditional rules files exist for historical reasons, but are no longer widely
1056N/Aused. In general, it's best to simply not specify the rules file, in order to
1056N/Ause the default rules selected automatically by the X server.
1056N/AFor each rules file there is a description file named <vendor-rules>.lst, for
1056N/Ainstance
base.lst which is located in the xkb configuration subdirectory rules
1056N/ALet's say you want to configure a PC-style American keyboard with 104 keys as
1056N/Adescribed in
base.lst. This can be done by simply writing several lines from
1056N/A Identifier "keyboard defaults"
1056N/AThe values of XkbModel and XkbLayout are really not surprising. The XkbOptions
1056N/Ahas been explicitly set to the empty set of parameters. The XkbVariant option
1056N/Ahas been left out. That means the default variant named basic is loaded.
1056N/AOf course, this can be also done at runtime using the utility setxkbmap. The
1056N/Ashell command loading the same keyboard mapping would look like:
1056N/Asetxkbmap -model pc104 -layout us -option ""
1056N/AThe configuration and the shell command would be very analogous for most other
1056N/Alayouts (internationalized mappings).
1056N/AIf you wanted to enable the Ctrl+Alt+Backspace sequence to kill the X server by
1056N/A Identifier "keyboard defaults"
1056N/A Option "XKbOptions" "terminate:ctrl_alt_bksp"
1056N/AThis would be equivalent to running the shell command:
1056N/Asetxkbmap -option "terminate:ctrl_alt_bksp"
1056N/AYou can use multi-layouts xkb configuration. What does it mean? Basically it
1056N/Aallows to load up to four different keyboard layouts at a time. Each such
1056N/Alayout would reside in its own group. The groups (unlike complete keyboard
1056N/Aremapping) can be switched very fast from one to another by a combination of
1056N/ALet's say you want to configure your new Logitech cordless desktop keyboard,
1056N/Ayou intend to use three different layouts at the same time - us, czech and
1056N/Agerman (in this order), and that you are used to Alt+Shift combination for
1056N/AThen the configuration snippet could look like this:
1056N/A Identifier "Logitech Cordless"
1056N/A Option "XkbModel" "logicordless"
1056N/A Option "XkbLayout" "us,cz,de"
1056N/A Option "XKbOptions" "grp:alt_shift_toggle"
1056N/AOf course, this can be also done at runtime using the utility setxkbmap. The
1056N/Ashell command loading the same keyboard mapping would look like:
1056N/Asetxkbmap -model logicordless -layout "us,cz,de" \
1056N/A -option "grp:alt_shift_toggle"
1056N/AEven More Advanced Configuration
1056N/AOkay, let's say you are more demanding. You do like the example above but you
1056N/Awant it to change a bit. Let's imagine you want the czech keyboard mapping to
1056N/Ause another variant but basic. The configuration snippet then changes into:
1056N/A Identifier "Logitech Cordless"
1056N/A Option "XkbModel" "logicordless"
1056N/A Option "XkbLayout" "us,cz,de"
1056N/A Option "XkbVariant" ",bksl,"
1056N/A Option "XKbOptions" "grp:alt_shift_toggle"
1056N/AThat seems tricky but it is not. The logic for settings of variants is the same
1056N/Aas for layouts, that means the first and the third variant settings are left
1056N/Aout (set to basic), the second is set to bksl (a special variant with an
1056N/Aenhanced definition of the backslash key).
1056N/AAnalogously, the loading runtime will change to:
1056N/Asetxkbmap -model logicordless -layout "us,cz,de" \
1056N/A -variant ",bksl," -option "grp:alt_shift_toggle"
1056N/AFor a list of available options, with a short decription of what they do, see
1056N/Athe section starting with “! option” in the rules/*.lst files.
1056N/AKeymap configuration is the way formerly used to configure xkb. The user
1056N/Aincluded a special keymap file which specified the direct xkb configuration.
1056N/AThis method has been obsoleted by previously described rules files which are
1056N/Afar more flexible and allow simpler and more intuitive syntax. It is preserved
1056N/Amerely for compatibility reasons and should be avoided if possible.