1972599cfSmrg<?xml version="1.0" encoding="UTF-8"?>
2972599cfSmrg<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3972599cfSmrg          "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
4972599cfSmrg[
5972599cfSmrg<!ENTITY % defs SYSTEM "defs.ent"> %defs;
6972599cfSmrg]>
7972599cfSmrg
8972599cfSmrg<article id='XKB-Config'>
9972599cfSmrg
10972599cfSmrg  <articleinfo>
11972599cfSmrg
12972599cfSmrg    <title>The XKB Configuration Guide</title>
13972599cfSmrg    <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo>
14972599cfSmrg    <authorgroup>
15972599cfSmrg      <author>
16972599cfSmrg	<firstname>Kamil</firstname><surname>Toman</surname>
17972599cfSmrg      </author>
18972599cfSmrg      <author>
19972599cfSmrg	<firstname>Ivan</firstname><othername>U.</othername>
20972599cfSmrg	<surname>Pascal</surname>
21972599cfSmrg      </author>
22972599cfSmrg    </authorgroup>
23972599cfSmrg    <pubdate>November 2010</pubdate>
24972599cfSmrg
25972599cfSmrg    <abstract>
26972599cfSmrg
27972599cfSmrg      <para>
28972599cfSmrgThis document describes how to configure Xorg XKB from a user's point
29972599cfSmrgof view. It covers basic configuration syntax and gives also a few examples.
30972599cfSmrg      </para>
31972599cfSmrg      <para>
32972599cfSmrgThis version covers Xorg server versions 1.8 and later, used with the
33972599cfSmrgdata files from the <ulink
349dd7914aSmrgurl="https://www.freedesktop.org/wiki/Software/XKeyboardConfig"
35972599cfSmrg>xkeyboard-config</ulink> project.
36972599cfSmrg      </para>
37972599cfSmrg
38972599cfSmrg    </abstract>
39972599cfSmrg
40972599cfSmrg  </articleinfo>
41972599cfSmrg
42972599cfSmrg  <sect1 id='Overview'>
43972599cfSmrg    <title>Overview</title>
44972599cfSmrg
45972599cfSmrg    <para>
46972599cfSmrgThe XKB configuration is decomposed into a number of components. Selecting
47972599cfSmrgproper parts and combining them back you can achieve most of the configurations
48972599cfSmrgyou might need. Unless you have a completely atypical keyboard you really don't
49972599cfSmrgneed to touch any of the xkb configuration files.
50972599cfSmrg    </para>
51972599cfSmrg
52972599cfSmrg    <para>
53972599cfSmrgSome desktop environments now provide integrated graphical configuration
54972599cfSmrgtools for setting XKB configuration as part of your desktop session.  The
55972599cfSmrginstructions in this document are provided for those without such support,
56972599cfSmrgthose who need to configure XKB before the session startup (such as at the
57972599cfSmrglogin screen), or those who need to perform more advanced configuration
58972599cfSmrgthan those tools provide.
59972599cfSmrg    </para>
60972599cfSmrg
61972599cfSmrg  </sect1>
62972599cfSmrg
63972599cfSmrg  <sect1 id='Selecting_XKB_Configuration'>
64972599cfSmrg    <title>Selecting XKB Configuration</title>
65972599cfSmrg
66972599cfSmrg    <para>
67972599cfSmrgThe easiest and the most natural way to specify a keyboard mapping is to use
68972599cfSmrgthe <literal remap="tt">rules</literal> component. As its name suggests it describes a number of
69972599cfSmrggeneral rules to combine all bits and pieces into a valid and useful keyboard
70972599cfSmrgmapping. All you need to do is to select a suitable rules file and then to
71972599cfSmrgfeed it with a few parameters that will adjust the keyboard behaviour to
72972599cfSmrgfulfill your needs.
73972599cfSmrg    </para>
74972599cfSmrg
75972599cfSmrg    <para>
76972599cfSmrg      The parameters are:
77972599cfSmrg
78972599cfSmrg      <variablelist>
79972599cfSmrg	<varlistentry>
80972599cfSmrg	  <term><option>XkbRules</option></term>
81972599cfSmrg	  <listitem><para>
82972599cfSmrgfiles of rules to be used for keyboard mapping composition
83972599cfSmrg	  </para></listitem>
84972599cfSmrg	</varlistentry>
85972599cfSmrg
86972599cfSmrg	<varlistentry>
87972599cfSmrg	  <term><option>XkbModel</option></term>
88972599cfSmrg	  <listitem><para>
89972599cfSmrg name of the model of your keyboard type
90972599cfSmrg	  </para></listitem>
91972599cfSmrg	</varlistentry>
92972599cfSmrg
93972599cfSmrg	<varlistentry>
94972599cfSmrg	  <term><option>XkbLayout</option></term>
95972599cfSmrg	  <listitem><para>
96972599cfSmrg layout(s) you intend to use
97972599cfSmrg	  </para></listitem>
98972599cfSmrg	</varlistentry>
99972599cfSmrg
100972599cfSmrg	<varlistentry>
101972599cfSmrg	  <term><option>XkbVariant</option></term>
102972599cfSmrg	  <listitem><para>
103972599cfSmrg variant(s) of the layout you intend to use
104972599cfSmrg	  </para></listitem>
105972599cfSmrg	</varlistentry>
106972599cfSmrg
107972599cfSmrg	<varlistentry>
108972599cfSmrg	  <term><option>XkbOptions</option></term>
109972599cfSmrg	  <listitem><para>
110972599cfSmrg extra xkb configuration options
111972599cfSmrg	  </para></listitem>
112972599cfSmrg	</varlistentry>
113972599cfSmrg
114972599cfSmrg      </variablelist>
115972599cfSmrg
116972599cfSmrg    </para>
117972599cfSmrg
118972599cfSmrg    <para>
119972599cfSmrgThe rules file used depends on your system.  The rules files commonly
120972599cfSmrgused with Xorg are provided by the <ulink
1219dd7914aSmrgurl="https://www.freedesktop.org/wiki/Software/XKeyboardConfig"
122972599cfSmrg>xkeyboard-config</ulink> project.
123972599cfSmrgOn Linux systems, the <filename>evdev</filename> rules are most
124972599cfSmrgcommonly used, on other systems the <filename>base</filename> rules
125972599cfSmrgare used.  Some additional rules files exist for historical reasons,
126972599cfSmrgbut are no longer widely used.  In general, it's best to simply not
127972599cfSmrgspecify the rules file, in order to use the default rules selected
128972599cfSmrgautomatically by the X server.
129972599cfSmrg    </para>
130972599cfSmrg    <para>
131972599cfSmrgFor each rules file there is a description file named
132972599cfSmrg<filename>&lt;<replaceable>vendor-rules</replaceable>&gt;.lst</filename>,
133972599cfSmrgfor instance <filename>base.lst</filename> which is located in
134972599cfSmrgthe xkb configuration subdirectory <filename>rules</filename>
135972599cfSmrg(for example <filename>/usr/share/X11/xkb/rules</filename>).
136972599cfSmrg    </para>
137972599cfSmrg
138972599cfSmrg    <sect2 id='Basic_Configuration'>
139972599cfSmrg      <title>Basic Configuration</title>
140972599cfSmrg
141972599cfSmrg      <para>
142972599cfSmrgLet's say you want to configure a PC-style American keyboard with 104
143972599cfSmrgkeys as described in <filename>base.lst</filename>.  This can be done
144972599cfSmrgby simply writing several lines from below to a new configuration file
145972599cfSmrgin <filename>/etc/X11/xorg.conf.d</filename>, such
146972599cfSmrgas <filename>/etc/X11/xorg.conf.d/90-custom-kbd.conf</filename>.
147972599cfSmrg
148972599cfSmrg
149972599cfSmrg	<screen>
150972599cfSmrgSection "InputClass"
151972599cfSmrg    Identifier "keyboard defaults"
152972599cfSmrg    MatchIsKeyboard "on"
153972599cfSmrg
154972599cfSmrg    Option "XkbModel" "pc104"
155972599cfSmrg    Option "XkbLayout" "us"
156972599cfSmrg    Option "XKbOptions" ""
157972599cfSmrgEndSection
158972599cfSmrg	</screen>
159972599cfSmrg
160972599cfSmrgThe values of <option>XkbModel</option> and <option>XkbLayout</option> are
161972599cfSmrgreally not surprising. The <option>XkbOptions</option>
162972599cfSmrghas been explicitly set to the empty set of parameters.
163972599cfSmrgThe <option>XkbVariant</option> option has been left out.
164972599cfSmrgThat means the default variant named <literal remap="tt">basic</literal>
165972599cfSmrgis loaded.
166972599cfSmrg      </para>
167972599cfSmrg
168972599cfSmrg      <para>
169972599cfSmrgOf course, this can be also done at runtime using the utility
170972599cfSmrg<command>setxkbmap</command>.
171972599cfSmrgThe shell command loading the same keyboard mapping would look like:
172972599cfSmrg
173972599cfSmrg	<screen>
174972599cfSmrgsetxkbmap -model pc104 -layout us -option ""
175972599cfSmrg	</screen>
176972599cfSmrg
177972599cfSmrgThe configuration and the shell command would be very analogous
178972599cfSmrgfor most other layouts (internationalized mappings).
179972599cfSmrg      </para>
180972599cfSmrg
181972599cfSmrg      <para id="zap">
182972599cfSmrgIf you wanted to enable the <keycombo action='simul'><keycap>Ctrl</keycap>
183972599cfSmrg<keycap>Alt</keycap><keycap>Backspace</keycap></keycombo> sequence to kill
184972599cfSmrgthe X server by default, you could create a configuration snippet
185972599cfSmrg<filename>/etc/X11/xorg.conf.d/90-zap.conf</filename> containing:
186972599cfSmrg
187972599cfSmrg	<screen>
188972599cfSmrgSection "InputClass"
189972599cfSmrg    Identifier "keyboard defaults"
190972599cfSmrg    MatchIsKeyboard "on"
191972599cfSmrg
192972599cfSmrg    Option "XKbOptions" "terminate:ctrl_alt_bksp"
193972599cfSmrgEndSection
194972599cfSmrg	</screen>
195972599cfSmrg
196972599cfSmrgThis would be equivalent to running the shell command:
197972599cfSmrg
198972599cfSmrg	<screen>
199972599cfSmrgsetxkbmap -option "terminate:ctrl_alt_bksp"
200972599cfSmrg	</screen>
201972599cfSmrg      </para>
202972599cfSmrg
203972599cfSmrg    </sect2>
204972599cfSmrg
205972599cfSmrg    <sect2 id='Advanced_Configuration'>
206972599cfSmrg      <title>Advanced Configuration</title>
207972599cfSmrg
208972599cfSmrg      <para>
209972599cfSmrgYou can use multi-layouts xkb configuration.
210972599cfSmrgWhat does it mean? Basically it allows to load up to four different
211972599cfSmrgkeyboard layouts at a time. Each such layout would reside in its
212972599cfSmrgown group. The groups (unlike complete keyboard remapping) can be
213972599cfSmrgswitched very fast from one to another by a combination of keys.
214972599cfSmrg      </para>
215972599cfSmrg
216972599cfSmrg      <para>
217972599cfSmrgLet's say you want to configure your new Logitech cordless desktop
218972599cfSmrgkeyboard, you intend to use three different layouts at the same
219972599cfSmrgtime - us, czech and german (in this order), and that you are used to
220972599cfSmrg<keycombo action='simul'><keycap>Alt</keycap><keycap>Shift</keycap></keycombo>
221972599cfSmrgcombination for switching among them.
222972599cfSmrg      </para>
223972599cfSmrg
224972599cfSmrg      <para>
225972599cfSmrgThen the configuration snippet could look like this:
226972599cfSmrg
227972599cfSmrg	<screen>
228972599cfSmrgSection "InputClass"
229972599cfSmrg    Identifier "Logitech Cordless"
230972599cfSmrg    MatchIsKeyboard   "on"
231972599cfSmrg
232972599cfSmrg    Option "XkbModel" "logicordless"
233972599cfSmrg    Option "XkbLayout" "us,cz,de"
234972599cfSmrg    Option "XKbOptions" "grp:alt_shift_toggle"
235972599cfSmrgEndSection
236972599cfSmrg	</screen>
237972599cfSmrg
238972599cfSmrgOf course, this can be also done at runtime using the utility
239972599cfSmrg<command>setxkbmap</command>.
240972599cfSmrgThe shell command loading the same keyboard mapping would look like:
241972599cfSmrg
242972599cfSmrg	<screen>
243972599cfSmrgsetxkbmap -model logicordless -layout "us,cz,de" \
244972599cfSmrg         -option "grp:alt_shift_toggle"
245972599cfSmrg	</screen>
246972599cfSmrg
247972599cfSmrg      </para>
248972599cfSmrg
249972599cfSmrg    </sect2>
250972599cfSmrg
251972599cfSmrg    <sect2 id='Even_More_Advanced_Configuration'>
252972599cfSmrg      <title>Even More Advanced Configuration</title>
253972599cfSmrg
254972599cfSmrg      <para>
255972599cfSmrgOkay, let's say you are more demanding. You do like the example
256972599cfSmrgabove but you want it to change a bit. Let's imagine you want
257972599cfSmrgthe czech keyboard mapping to use another variant but basic.
258972599cfSmrgThe configuration snippet then changes into:
259972599cfSmrg
260972599cfSmrg	<screen>
261972599cfSmrgSection "InputClass"
262972599cfSmrg    Identifier "Logitech Cordless"
263972599cfSmrg    MatchIsKeyboard   "on"
264972599cfSmrg
265972599cfSmrg    Option "XkbModel" "logicordless"
266972599cfSmrg    Option "XkbLayout" "us,cz,de"
267972599cfSmrg    Option "XkbVariant" ",bksl,"
268972599cfSmrg    Option "XKbOptions" "grp:alt_shift_toggle"
269972599cfSmrgEndSection
270972599cfSmrg	</screen>
271972599cfSmrg
272972599cfSmrgThat seems tricky but it is not. The logic for settings of variants
273972599cfSmrgis the same as for layouts, that means the first and the third variant
274972599cfSmrgsettings are left out (set to <literal remap="tt">basic</literal>),
275972599cfSmrgthe second is set to <literal remap="tt">bksl</literal> (a special
276972599cfSmrgvariant with an enhanced definition of the backslash key).
277972599cfSmrg      </para>
278972599cfSmrg
279972599cfSmrg      <para>
280972599cfSmrgAnalogously, the loading runtime will change to:
281972599cfSmrg
282972599cfSmrg	<screen>
283972599cfSmrgsetxkbmap -model logicordless -layout "us,cz,de" \
284972599cfSmrg         -variant ",bksl," -option "grp:alt_shift_toggle"
285972599cfSmrg	</screen>
286972599cfSmrg
287972599cfSmrg      </para>
288972599cfSmrg
289972599cfSmrg    </sect2>
290972599cfSmrg
291972599cfSmrg    <sect2 id='Basic_Global_Options'>
292972599cfSmrg      <title>Basic Global Options</title>
293972599cfSmrg
294972599cfSmrg      <para>
2955eeb4e8fSmrgFor a list of available options, with a short description of what they do,
296972599cfSmrgsee the section starting with <quote><literal>! option</literal></quote> in the
297972599cfSmrg<filename>rules/*.lst</filename> files.
298972599cfSmrg      </para>
299972599cfSmrg
300972599cfSmrg<!--
301972599cfSmrg  TODO: More detailed descriptions of options. Users often get confused.
302972599cfSmrg-->
303972599cfSmrg
304972599cfSmrg    </sect2>
305972599cfSmrg
306972599cfSmrg  </sect1>
307972599cfSmrg
308972599cfSmrg  <sect1 id='Keymap_XKB_Configuration'>
309972599cfSmrg    <title>Keymap XKB Configuration</title>
310972599cfSmrg
311972599cfSmrg    <para>
312972599cfSmrgKeymap configuration is the way formerly used to configure xkb. The
313972599cfSmrguser included a special keymap file which specified the direct xkb
314972599cfSmrgconfiguration. This method has been obsoleted by previously described
315972599cfSmrgrules files which are far more flexible and allow simpler and more
316972599cfSmrgintuitive syntax. It is preserved merely for compatibility reasons and
317972599cfSmrgshould be avoided if possible.
318972599cfSmrg    </para>
319972599cfSmrg
320972599cfSmrg  </sect1>
321972599cfSmrg
322972599cfSmrg</article>
323