1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 3 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" 4[ 5<!ENTITY % defs SYSTEM "defs.ent"> %defs; 6]> 7 8<article id='XKB-Config'> 9 10 <articleinfo> 11 12 <title>The XKB Configuration Guide</title> 13 <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo> 14 <authorgroup> 15 <author> 16 <firstname>Kamil</firstname><surname>Toman</surname> 17 </author> 18 <author> 19 <firstname>Ivan</firstname><othername>U.</othername> 20 <surname>Pascal</surname> 21 </author> 22 </authorgroup> 23 <pubdate>November 2010</pubdate> 24 25 <abstract> 26 27 <para> 28This document describes how to configure Xorg XKB from a user's point 29of view. It covers basic configuration syntax and gives also a few examples. 30 </para> 31 <para> 32This version covers Xorg server versions 1.8 and later, used with the 33data files from the <ulink 34url="https://www.freedesktop.org/wiki/Software/XKeyboardConfig" 35>xkeyboard-config</ulink> project. 36 </para> 37 38 </abstract> 39 40 </articleinfo> 41 42 <sect1 id='Overview'> 43 <title>Overview</title> 44 45 <para> 46The XKB configuration is decomposed into a number of components. Selecting 47proper parts and combining them back you can achieve most of the configurations 48you might need. Unless you have a completely atypical keyboard you really don't 49need to touch any of the xkb configuration files. 50 </para> 51 52 <para> 53Some desktop environments now provide integrated graphical configuration 54tools for setting XKB configuration as part of your desktop session. The 55instructions in this document are provided for those without such support, 56those who need to configure XKB before the session startup (such as at the 57login screen), or those who need to perform more advanced configuration 58than those tools provide. 59 </para> 60 61 </sect1> 62 63 <sect1 id='Selecting_XKB_Configuration'> 64 <title>Selecting XKB Configuration</title> 65 66 <para> 67The easiest and the most natural way to specify a keyboard mapping is to use 68the <literal remap="tt">rules</literal> component. As its name suggests it describes a number of 69general rules to combine all bits and pieces into a valid and useful keyboard 70mapping. All you need to do is to select a suitable rules file and then to 71feed it with a few parameters that will adjust the keyboard behaviour to 72fulfill your needs. 73 </para> 74 75 <para> 76 The parameters are: 77 78 <variablelist> 79 <varlistentry> 80 <term><option>XkbRules</option></term> 81 <listitem><para> 82files of rules to be used for keyboard mapping composition 83 </para></listitem> 84 </varlistentry> 85 86 <varlistentry> 87 <term><option>XkbModel</option></term> 88 <listitem><para> 89 name of the model of your keyboard type 90 </para></listitem> 91 </varlistentry> 92 93 <varlistentry> 94 <term><option>XkbLayout</option></term> 95 <listitem><para> 96 layout(s) you intend to use 97 </para></listitem> 98 </varlistentry> 99 100 <varlistentry> 101 <term><option>XkbVariant</option></term> 102 <listitem><para> 103 variant(s) of the layout you intend to use 104 </para></listitem> 105 </varlistentry> 106 107 <varlistentry> 108 <term><option>XkbOptions</option></term> 109 <listitem><para> 110 extra xkb configuration options 111 </para></listitem> 112 </varlistentry> 113 114 </variablelist> 115 116 </para> 117 118 <para> 119The rules file used depends on your system. The rules files commonly 120used with Xorg are provided by the <ulink 121url="https://www.freedesktop.org/wiki/Software/XKeyboardConfig" 122>xkeyboard-config</ulink> project. 123On Linux systems, the <filename>evdev</filename> rules are most 124commonly used, on other systems the <filename>base</filename> rules 125are used. Some additional rules files exist for historical reasons, 126but are no longer widely used. In general, it's best to simply not 127specify the rules file, in order to use the default rules selected 128automatically by the X server. 129 </para> 130 <para> 131For each rules file there is a description file named 132<filename><<replaceable>vendor-rules</replaceable>>.lst</filename>, 133for instance <filename>base.lst</filename> which is located in 134the xkb configuration subdirectory <filename>rules</filename> 135(for example <filename>/usr/share/X11/xkb/rules</filename>). 136 </para> 137 138 <sect2 id='Basic_Configuration'> 139 <title>Basic Configuration</title> 140 141 <para> 142Let's say you want to configure a PC-style American keyboard with 104 143keys as described in <filename>base.lst</filename>. This can be done 144by simply writing several lines from below to a new configuration file 145in <filename>/etc/X11/xorg.conf.d</filename>, such 146as <filename>/etc/X11/xorg.conf.d/90-custom-kbd.conf</filename>. 147 148 149 <screen> 150Section "InputClass" 151 Identifier "keyboard defaults" 152 MatchIsKeyboard "on" 153 154 Option "XkbModel" "pc104" 155 Option "XkbLayout" "us" 156 Option "XKbOptions" "" 157EndSection 158 </screen> 159 160The values of <option>XkbModel</option> and <option>XkbLayout</option> are 161really not surprising. The <option>XkbOptions</option> 162has been explicitly set to the empty set of parameters. 163The <option>XkbVariant</option> option has been left out. 164That means the default variant named <literal remap="tt">basic</literal> 165is loaded. 166 </para> 167 168 <para> 169Of course, this can be also done at runtime using the utility 170<command>setxkbmap</command>. 171The shell command loading the same keyboard mapping would look like: 172 173 <screen> 174setxkbmap -model pc104 -layout us -option "" 175 </screen> 176 177The configuration and the shell command would be very analogous 178for most other layouts (internationalized mappings). 179 </para> 180 181 <para id="zap"> 182If you wanted to enable the <keycombo action='simul'><keycap>Ctrl</keycap> 183<keycap>Alt</keycap><keycap>Backspace</keycap></keycombo> sequence to kill 184the X server by default, you could create a configuration snippet 185<filename>/etc/X11/xorg.conf.d/90-zap.conf</filename> containing: 186 187 <screen> 188Section "InputClass" 189 Identifier "keyboard defaults" 190 MatchIsKeyboard "on" 191 192 Option "XKbOptions" "terminate:ctrl_alt_bksp" 193EndSection 194 </screen> 195 196This would be equivalent to running the shell command: 197 198 <screen> 199setxkbmap -option "terminate:ctrl_alt_bksp" 200 </screen> 201 </para> 202 203 </sect2> 204 205 <sect2 id='Advanced_Configuration'> 206 <title>Advanced Configuration</title> 207 208 <para> 209You can use multi-layouts xkb configuration. 210What does it mean? Basically it allows to load up to four different 211keyboard layouts at a time. Each such layout would reside in its 212own group. The groups (unlike complete keyboard remapping) can be 213switched very fast from one to another by a combination of keys. 214 </para> 215 216 <para> 217Let's say you want to configure your new Logitech cordless desktop 218keyboard, you intend to use three different layouts at the same 219time - us, czech and german (in this order), and that you are used to 220<keycombo action='simul'><keycap>Alt</keycap><keycap>Shift</keycap></keycombo> 221combination for switching among them. 222 </para> 223 224 <para> 225Then the configuration snippet could look like this: 226 227 <screen> 228Section "InputClass" 229 Identifier "Logitech Cordless" 230 MatchIsKeyboard "on" 231 232 Option "XkbModel" "logicordless" 233 Option "XkbLayout" "us,cz,de" 234 Option "XKbOptions" "grp:alt_shift_toggle" 235EndSection 236 </screen> 237 238Of course, this can be also done at runtime using the utility 239<command>setxkbmap</command>. 240The shell command loading the same keyboard mapping would look like: 241 242 <screen> 243setxkbmap -model logicordless -layout "us,cz,de" \ 244 -option "grp:alt_shift_toggle" 245 </screen> 246 247 </para> 248 249 </sect2> 250 251 <sect2 id='Even_More_Advanced_Configuration'> 252 <title>Even More Advanced Configuration</title> 253 254 <para> 255Okay, let's say you are more demanding. You do like the example 256above but you want it to change a bit. Let's imagine you want 257the czech keyboard mapping to use another variant but basic. 258The configuration snippet then changes into: 259 260 <screen> 261Section "InputClass" 262 Identifier "Logitech Cordless" 263 MatchIsKeyboard "on" 264 265 Option "XkbModel" "logicordless" 266 Option "XkbLayout" "us,cz,de" 267 Option "XkbVariant" ",bksl," 268 Option "XKbOptions" "grp:alt_shift_toggle" 269EndSection 270 </screen> 271 272That seems tricky but it is not. The logic for settings of variants 273is the same as for layouts, that means the first and the third variant 274settings are left out (set to <literal remap="tt">basic</literal>), 275the second is set to <literal remap="tt">bksl</literal> (a special 276variant with an enhanced definition of the backslash key). 277 </para> 278 279 <para> 280Analogously, the loading runtime will change to: 281 282 <screen> 283setxkbmap -model logicordless -layout "us,cz,de" \ 284 -variant ",bksl," -option "grp:alt_shift_toggle" 285 </screen> 286 287 </para> 288 289 </sect2> 290 291 <sect2 id='Basic_Global_Options'> 292 <title>Basic Global Options</title> 293 294 <para> 295For a list of available options, with a short description of what they do, 296see the section starting with <quote><literal>! option</literal></quote> in the 297<filename>rules/*.lst</filename> files. 298 </para> 299 300<!-- 301 TODO: More detailed descriptions of options. Users often get confused. 302--> 303 304 </sect2> 305 306 </sect1> 307 308 <sect1 id='Keymap_XKB_Configuration'> 309 <title>Keymap XKB Configuration</title> 310 311 <para> 312Keymap configuration is the way formerly used to configure xkb. The 313user included a special keymap file which specified the direct xkb 314configuration. This method has been obsoleted by previously described 315rules files which are far more flexible and allow simpler and more 316intuitive syntax. It is preserved merely for compatibility reasons and 317should be avoided if possible. 318 </para> 319 320 </sect1> 321 322</article> 323