README.enhancing revision 1.1 1 1.1 mrg How to further enhance XKB configuration
2 1.1 mrg
3 1.1 mrg Kamil Toman, Ivan U. Pascal
4 1.1 mrg
5 1.1 mrg 25 November 2002
6 1.1 mrg
7 1.1 mrg Abstract
8 1.1 mrg
9 1.1 mrg This guide is aimed to relieve one's labour to create a new (inter-
10 1.1 mrg nationalized) keyboard layout. Unlike other documents this guide
11 1.1 mrg accents the keymap developer's point of view.
12 1.1 mrg
13 1.1 mrg 1. Overview
14 1.1 mrg
15 1.1 mrg The developer of a new layout should read the xkb protocol specification (The
16 1.1 mrg X Keyboard Extension: Protocol Specification <URL:http://www.x-
17 1.1 mrg docs.org/XKB/XKBproto.pdf>) at least to clarify for himself some xkb-specific
18 1.1 mrg terms used in this document and elsewhere in xkb configuration. Also it shows
19 1.1 mrg wise to understand how the X server and a client digest their keyboard inputs
20 1.1 mrg (with and without xkb).
21 1.1 mrg
22 1.1 mrg A useful source is also Ivan Pascal's text about xkb configuration
23 1.1 mrg <URL:http://www.tsu.ru/~pascal/en/xkb> often referenced throughout this docu-
24 1.1 mrg ment.
25 1.1 mrg
26 1.1 mrg Note that this document covers only enhancements which are to be made to
27 1.1 mrg XFree86 version 4.3.x and above.
28 1.1 mrg
29 1.1 mrg 2. The Basics
30 1.1 mrg
31 1.1 mrg At the startup (or at later at user's command) X server starts its xkb key-
32 1.1 mrg board module extension and reads data from a compiled configuration file.
33 1.1 mrg
34 1.1 mrg This compiled configuration file is prepared by the program xkbcomp which
35 1.1 mrg behaves altogether as an ordinary compiler (see man xkbcomp). Its input are
36 1.1 mrg human readable xkb configuration files which are verified and then composed
37 1.1 mrg into a useful xkb configuration. Users don't need to mess with xkbcomp them-
38 1.1 mrg selves, for them it is invisible. Usually, it is started upon X server
39 1.1 mrg startup.
40 1.1 mrg
41 1.1 mrg As you probably already know, the xkb configuration consists of five main
42 1.1 mrg modules:
43 1.1 mrg
44 1.1 mrg Keycodes
45 1.1 mrg Tables that defines translation from keyboard scan codes into
46 1.1 mrg reasonable symbolic names, maximum, minimum legal keycodes, sym-
47 1.1 mrg bolic aliases and description of physically present LED-indica-
48 1.1 mrg tors. The primary sence of this component is to allow definitions
49 1.1 mrg of maps of symbols (see below) to be independent of physical key-
50 1.1 mrg board scancodes. There are two main naming conventions for sym-
51 1.1 mrg bolic names (always four bytes long):
52 1.1 mrg
53 1.1 mrg o names which express some traditional meaning like <SPCE>
54 1.1 mrg (stands for space bar) or
55 1.1 mrg
56 1.1 mrg o names which express some relative positioning on a key-
57 1.1 mrg board, for example <AE01> (an exclamation mark on US key-
58 1.1 mrg boards), on the right there are keys <AE02>, <AE03> etc.
59 1.1 mrg
60 1.1 mrg Types
61 1.1 mrg Types describe how the produced key is changed by active modi-
62 1.1 mrg fiers (like Shift, Control, Alt, ...). There are several prede-
63 1.1 mrg fined types which cover most of used combinations.
64 1.1 mrg
65 1.1 mrg Compat
66 1.1 mrg Compatibility component defines internal behaviour of modifiers.
67 1.1 mrg Using compat component you can assign various actions (elabo-
68 1.1 mrg rately described in xkb specification) to key events. This is
69 1.1 mrg also the place where LED-indicators behaviour is defined.
70 1.1 mrg
71 1.1 mrg Symbols
72 1.1 mrg For i18n purposes, this is the most important table. It defines
73 1.1 mrg what values (=symbols) are assigned to what keycodes (represented
74 1.1 mrg by their symbolic name, see above). There may be defined more
75 1.1 mrg than one value for each key and then it depends on a key type and
76 1.1 mrg on modifiers state (respective compat component) which value will
77 1.1 mrg be the resulting one.
78 1.1 mrg
79 1.1 mrg Geometry
80 1.1 mrg Geometry files aren't used by xkb itself but they may be used by
81 1.1 mrg some external programs to depict a keyboard image.
82 1.1 mrg
83 1.1 mrg All these components have the files located in xkb configuration tree in sub-
84 1.1 mrg directories with the same names (usually in /usr/lib/X11/xkb).
85 1.1 mrg
86 1.1 mrg 3. Enhancing XKB Configuration
87 1.1 mrg
88 1.1 mrg Most of xkb enhancements concerns a need to define new output symbols for the
89 1.1 mrg some input key events. In other words, a need to define a new symbol map (for
90 1.1 mrg a new language, standard or just to feel more comfortable when typing text).
91 1.1 mrg
92 1.1 mrg What do you need to do? Generally, you have to define following things:
93 1.1 mrg
94 1.1 mrg o the map of symbols itself
95 1.1 mrg
96 1.1 mrg o the rules to allow users to select the new mapping
97 1.1 mrg
98 1.1 mrg o the description of the new layout
99 1.1 mrg
100 1.1 mrg First of all, it is good to go through existing layouts and to examine them
101 1.1 mrg if there is something you could easily adjust to fit your needs. Even if
102 1.1 mrg there is nothing similar you may get some ideas about basic concepts and used
103 1.1 mrg tricks.
104 1.1 mrg
105 1.1 mrg 3.1 Levels And Groups
106 1.1 mrg
107 1.1 mrg Since XFree86 4.3.0 you can use multi-layout concept of xkb configuration.
108 1.1 mrg Though it is still in boundaries of xkb protocol and general ideas, the
109 1.1 mrg keymap designer must obey new rules when creating new maps. In exchange we
110 1.1 mrg get a more powerful and cleaner configuration system.
111 1.1 mrg
112 1.1 mrg Remember that it is the application which must decide which symbol matches
113 1.1 mrg which keycode according to effective modifier state. The X server itself
114 1.1 mrg sends only an input event message to. Of course, usually the general inter-
115 1.1 mrg pretation is processed by Xlib, Xaw, Motif, Qt, Gtk and similar libraries.
116 1.1 mrg The X server only supplies its mapping table (usually upon an application
117 1.1 mrg startup).
118 1.1 mrg
119 1.1 mrg You can think of the X server's symbol table as of a irregular table where
120 1.1 mrg each keycode has its row and where each combination of modifiers determines
121 1.1 mrg exactly one column. The resulting cell then gives the proper symbolic value.
122 1.1 mrg Not all keycodes need to bind different values for different combination of
123 1.1 mrg modifiers. <ENTER> key, for instance, usually doesn't depend on any modi-
124 1.1 mrg fiers so it its row has only one column defined.
125 1.1 mrg
126 1.1 mrg Note that in XKB there is no prior assumption that certain modifiers are
127 1.1 mrg bound to certain columns. By editing proper files (see keytypes (section 4.2,
128 1.1 mrg page 1)) this mapping can be changed as well.
129 1.1 mrg
130 1.1 mrg Unlike the original X protocol the XKB approach is far more flexible. It is
131 1.1 mrg comfortable to add one additional XKB term - group. You can think of a group
132 1.1 mrg as of a vector of columns per each keycode (naturally the dimension of this
133 1.1 mrg vector may differ for different keycodes). What is it good for? The group is
134 1.1 mrg not very useful unless you intend to use more than one logically different
135 1.1 mrg set of symbols (like more than one alphabet) defined in a single mapping ta-
136 1.1 mrg ble. But then, the group has a natural meaning - each symbol set has its own
137 1.1 mrg group and changing it means selecting a different one. XKB approach allows
138 1.1 mrg up to four different groups. The columns inside each group are called (shift)
139 1.1 mrg levels. The X server knows the current group and reports it together with
140 1.1 mrg modifier set and with a keycode in key events.
141 1.1 mrg
142 1.1 mrg To sum it up:
143 1.1 mrg
144 1.1 mrg o for each keycode XKB keyboard map contains up to four one-dimensional
145 1.1 mrg tables - groups (logically different symbol sets)
146 1.1 mrg
147 1.1 mrg o for each group of a keycode XKB keyboard map contains some columns -
148 1.1 mrg shift levels (values reached by combinations of Shift, Ctrl, Alt, ...
149 1.1 mrg modifiers)
150 1.1 mrg
151 1.1 mrg o different keycodes can have different number of groups
152 1.1 mrg
153 1.1 mrg o different groups of one keycode can have different number of shift lev-
154 1.1 mrg els
155 1.1 mrg
156 1.1 mrg o the current group number is tracked by X server
157 1.1 mrg
158 1.1 mrg It is clear that if you sanely define levels, groups and sanely bind modi-
159 1.1 mrg fiers and associated actions you can have simultaneously loaded up to four
160 1.1 mrg different symbol sets where each of them would reside in its own group.
161 1.1 mrg
162 1.1 mrg The multi-layout concept provides a facility to manipulate xkb groups and
163 1.1 mrg symbol definitions in a way that allows almost arbitrary composition of pre-
164 1.1 mrg defined symbol tables. To keep it fully functional you have to:
165 1.1 mrg
166 1.1 mrg o define all symbols only in the first group
167 1.1 mrg
168 1.1 mrg o (re)define any modifiers with extra care to avoid strange (anisometric)
169 1.1 mrg behaviour
170 1.1 mrg
171 1.1 mrg 4. Defining New Layouts
172 1.1 mrg
173 1.1 mrg See Some Words About XKB internals <URL:http://www.tsu.ru/~pas-
174 1.1 mrg cal/en/xkb/internals.html> for explanation of used xkb terms and problems
175 1.1 mrg addressed by XKB extension.
176 1.1 mrg
177 1.1 mrg See Common notes about XKB configuration files language
178 1.1 mrg <URL:http://www.tsu.ru/~pascal/en/xkb/gram-common.html> for more precise
179 1.1 mrg explanation of syntax of xkb configuration files.
180 1.1 mrg
181 1.1 mrg 4.1 Predefined XKB Symbol Sets
182 1.1 mrg
183 1.1 mrg If you are about to define some European symbol map extension, you might want
184 1.1 mrg to use on of four predefined latin alphabet layouts.
185 1.1 mrg
186 1.1 mrg Okay, let's assume you want extend an existing keymap and you want to over-
187 1.1 mrg ride a few keys. Let's take a simple U.K. keyboard as an example (defined in
188 1.1 mrg pc/gb):
189 1.1 mrg
190 1.1 mrg partial default alphanumeric_keys
191 1.1 mrg xkb_symbols "basic" {
192 1.1 mrg include "pc/latin"
193 1.1 mrg
194 1.1 mrg name[Group1]="Great Britain";
195 1.1 mrg
196 1.1 mrg key <AE02> { [ 2, quotedbl, twosuperior, oneeighth ] };
197 1.1 mrg key <AE03> { [ 3, sterling, threesuperior, sterling ] };
198 1.1 mrg key <AC11> { [apostrophe, at, dead_circumflex, dead_caron] };
199 1.1 mrg key <TLDE> { [ grave, notsign, bar, bar ] };
200 1.1 mrg key <BKSL> { [numbersign, asciitilde, dead_grave, dead_breve ] };
201 1.1 mrg key <RALT> { type[Group1]="TWO_LEVEL",
202 1.1 mrg [ ISO_Level3_Shift, Multi_key ] };
203 1.1 mrg
204 1.1 mrg modifier_map Mod5 { <RALT> };
205 1.1 mrg };
206 1.1 mrg
207 1.1 mrg It defines a new layout in basic variant as an extension of common latin
208 1.1 mrg alphabet layout. The layout (symbol set) name is set to "Great Britain".
209 1.1 mrg Then there are redefinitions of a few keycodes and a modifiers binding. As
210 1.1 mrg you can see the number of shift levels is the same for <AE02>, <AE03>,
211 1.1 mrg <AC11>, <TLDE> and <BKSL> keys but it differs from number of shift levels of
212 1.1 mrg <RALT>.
213 1.1 mrg
214 1.1 mrg Note that the <RALT> key itself is a binding key for Mod5 and that it serves
215 1.1 mrg like a shift modifier for LevelThree, together with Shift as a multi-key. It
216 1.1 mrg is a good habit to respect this rule in a new similar layout.
217 1.1 mrg
218 1.1 mrg Okay, you could now define more variants of your new layout besides basic
219 1.1 mrg simply by including (augmenting/overriding/...) the basic definition and
220 1.1 mrg altering what may be needed.
221 1.1 mrg
222 1.1 mrg 4.2 Key Types
223 1.1 mrg
224 1.1 mrg The differences in the number of columns (shift levels) are caused by a dif-
225 1.1 mrg ferent types of keys (see the types definition in section basics). Most key-
226 1.1 mrg codes have implicitly set the keytype in the included "pc/latin" file to
227 1.1 mrg "FOUR_LEVEL_ALPHABETIC". The only exception is <RALT> keycode which is
228 1.1 mrg explicitly set "TWO_LEVEL" keytype.
229 1.1 mrg
230 1.1 mrg All those names refer to pre-defined shift level schemes. Usually you can
231 1.1 mrg choose a suitable shift level scheme from default types scheme list in proper
232 1.1 mrg xkb component's subdirectory.
233 1.1 mrg
234 1.1 mrg The most used schemes are:
235 1.1 mrg
236 1.1 mrg ONE_LEVEL
237 1.1 mrg The key does not depend on any modifiers. The symbol from first
238 1.1 mrg level is always chosen.
239 1.1 mrg
240 1.1 mrg TWO_LEVEL
241 1.1 mrg The key uses a modifier Shift and may have two possible values.
242 1.1 mrg The second level may be chosen by Shift modifier. If Lock modi-
243 1.1 mrg fier (usually Caps-lock) applies the symbol is further processed
244 1.1 mrg using system-specific capitalization rules. If both Shift+Lock
245 1.1 mrg modifier apply the symbol from the second level is taken and cap-
246 1.1 mrg italization rules are applied (and usually have no effect).
247 1.1 mrg
248 1.1 mrg ALPHABETIC
249 1.1 mrg The key uses modifiers Shift and Lock. It may have two possible
250 1.1 mrg values. The second level may be chosen by Shift modifier. When
251 1.1 mrg Lock modifier applies, the symbol from the first level is taken
252 1.1 mrg and further processed using system-specific capitalization rules.
253 1.1 mrg If both Shift+Lock modifier apply the symbol from the first level
254 1.1 mrg is taken and no capitalization rules applied. This is often
255 1.1 mrg called shift-cancels-caps behaviour.
256 1.1 mrg
257 1.1 mrg THREE_LEVEL
258 1.1 mrg Is the same as TWO_LEVEL but it considers an extra modifier -
259 1.1 mrg LevelThree which can be used to gain the symbol value from the
260 1.1 mrg third level. If both Shift+LevelThree modifiers apply the value
261 1.1 mrg from the third level is also taken. As in TWO_LEVEL, the Lock
262 1.1 mrg modifier doesn't influence the resulting level. Only Shift and
263 1.1 mrg LevelThree are taken into that consideration. If the Lock modi-
264 1.1 mrg fier is active capitalization rules are applied on the resulting
265 1.1 mrg symbol.
266 1.1 mrg
267 1.1 mrg FOUR_LEVEL
268 1.1 mrg Is the same as THREE_LEVEL but unlike LEVEL_THREE if both
269 1.1 mrg Shift+LevelThree modifiers apply the symbol is taken from the
270 1.1 mrg fourth level.
271 1.1 mrg
272 1.1 mrg FOUR_LEVEL_ALPHABETIC
273 1.1 mrg Is similar to FOUR_LEVEL but also defines shift-cancels-caps
274 1.1 mrg behaviour as in ALPHABETIC. If Lock+LevelThree apply the symbol
275 1.1 mrg from the third level is taken and the capitalization rules are
276 1.1 mrg applied. If Lock+Shift+LevelThree apply the symbol from the
277 1.1 mrg third level is taken and no capitalization rules are applied.
278 1.1 mrg
279 1.1 mrg KEYPAD
280 1.1 mrg As the name suggest this scheme is primarily used for numeric
281 1.1 mrg keypads. The scheme considers two modifiers - Shift and NumLock.
282 1.1 mrg If none of modifiers applies the symbol from the first level is
283 1.1 mrg taken. If either Shift or NumLock modifiers apply the symbol from
284 1.1 mrg the second level is taken. If both Shift+NumLock modifiers apply
285 1.1 mrg the symbol from the first level is taken. Again, shift-cancels-
286 1.1 mrg caps variant.
287 1.1 mrg
288 1.1 mrg FOUR_LEVEL_KEYPAD
289 1.1 mrg Is similar to KEYPAD scheme but considers also LevelThree modi-
290 1.1 mrg fier. If LevelThree modifier applies the symbol from the third
291 1.1 mrg level is taken. If Shift+LevelThree or NumLock+LevelThree apply
292 1.1 mrg the symbol from the fourth level is taken. If all Shift+Num-
293 1.1 mrg Lock+LevelThree modifiers apply the symbol from the third level
294 1.1 mrg is taken. This also, shift-cancels-caps variant.
295 1.1 mrg
296 1.1 mrg FOUR_LEVEL_MIXED_KEYPAD
297 1.1 mrg A four-level keypad scheme where the first two levels are similar
298 1.1 mrg to the KEYPAD scheme (NumLock+Shift)
299 1.1 mrg LevelThree acts as an override providing access to two Shift-ed
300 1.1 mrg levels. When LevelThree is active we totally ignore NumLock state
301 1.1 mrg Intended for the digit area of the keypad
302 1.1 mrg
303 1.1 mrg FOUR_LEVEL_X
304 1.1 mrg A four-level scheme where the base level accepts no modifier,
305 1.1 mrg LevelThree provides two more Shift-ed levels like in the previous
306 1.1 mrg scheme, and Ctrl+Alt controls the fourth level
307 1.1 mrg Intended for the operator part of a keypad, though since NumLock
308 1.1 mrg plays no part, it is not keypad-specific
309 1.1 mrg
310 1.1 mrg Besides that, there are several schemes for special purposes:
311 1.1 mrg
312 1.1 mrg PC_CONTROL_LEVEL2
313 1.1 mrg It is similar to TWO_LEVEL scheme but it considers the Control
314 1.1 mrg modifier rather than Shift. That means, the symbol from the sec-
315 1.1 mrg ond level is chosen by Control rather than by Shift.
316 1.1 mrg
317 1.1 mrg PC_ALT_LEVEL2
318 1.1 mrg It is similar to TWO_LEVEL scheme but it considers the Alt modi-
319 1.1 mrg fier rather than Shift. That means, the symbol from the second
320 1.1 mrg level is chosen by Alt rather than by Shift.
321 1.1 mrg
322 1.1 mrg CTRL+ALT
323 1.1 mrg The key uses modifiers Alt and Control. It may have two possible
324 1.1 mrg values. If only one modifier (Alt or Control) applies the symbol
325 1.1 mrg from the first level is chosen. Only if both Alt+Control modi-
326 1.1 mrg fiers apply the symbol from the second level is chosen.
327 1.1 mrg
328 1.1 mrg SHIFT+ALT
329 1.1 mrg The key uses modifiers Shift and Alt. It may have two possible
330 1.1 mrg values. If only one modifier (Alt or Shift) applies the symbol
331 1.1 mrg from the first level is chosen. Only if both Alt+Shift modifiers
332 1.1 mrg apply the symbol from the second level is chosen.
333 1.1 mrg
334 1.1 mrg If needed, special caps schemes may be used. They redefine the standard
335 1.1 mrg behaviour of all *ALPHABETIC types. The layouts (maps of symbols) with keys
336 1.1 mrg defined in respective types then automatically change their behaviour accord-
337 1.1 mrg ingly. Possible redefinitions are:
338 1.1 mrg
339 1.1 mrg o internal
340 1.1 mrg
341 1.1 mrg o internal_nocancel
342 1.1 mrg
343 1.1 mrg o shift
344 1.1 mrg
345 1.1 mrg o shift_nocancel
346 1.1 mrg
347 1.1 mrg None of these schemes should be used directly. They are defined merely for
348 1.1 mrg 'caps:' xkb options (used to globally change the layouts behaviour).
349 1.1 mrg
350 1.1 mrg Don't alter any of existing key types. If you need a different behaviour cre-
351 1.1 mrg ate a new one.
352 1.1 mrg
353 1.1 mrg 4.2.1 More On Definitions Of Types
354 1.1 mrg
355 1.1 mrg When the XKB software deals with a separate type description it gets a com-
356 1.1 mrg plete list of modifiers that should be taken into account from the 'modi-
357 1.1 mrg fiers=<list of modifiers>' list and expects that a set of 'map[<combination
358 1.1 mrg of modifiers>]=<list of modifiers>' instructions that contain the mapping for
359 1.1 mrg each combination of modifiers mentioned in that list. Modifiers that are not
360 1.1 mrg explicitly listed are NOT taken into account when the resulting shift level
361 1.1 mrg is computed. If some combination is omitted the program (subroutine) should
362 1.1 mrg choose the first level for this combination (a quite reasonable behavior).
363 1.1 mrg
364 1.1 mrg Lets consider an example with two modifiers ModOne and ModTwo:
365 1.1 mrg
366 1.1 mrg type "..." {
367 1.1 mrg modifiers = ModOne+ModTwo;
368 1.1 mrg map[None] = Level1;
369 1.1 mrg map[ModOne] = Level2;
370 1.1 mrg };
371 1.1 mrg
372 1.1 mrg In this case the map statements for ModTwo only and ModOne+ModTwo are omit-
373 1.1 mrg ted. It means that if the ModTwo is active the subroutine can't found
374 1.1 mrg explicit mapping for such combination an will use the default level i.e.
375 1.1 mrg Level1.
376 1.1 mrg
377 1.1 mrg But in the case the type described as:
378 1.1 mrg
379 1.1 mrg type "..." {
380 1.1 mrg modifiers = ModOne;
381 1.1 mrg map[None] = Level1;
382 1.1 mrg map[ModOne] = Level2;
383 1.1 mrg };
384 1.1 mrg
385 1.1 mrg the ModTwo will not be taken into account and the resulting level depends on
386 1.1 mrg the ModOne state only. That means, ModTwo alone produces the Level1 but the
387 1.1 mrg combination ModOne+ModTwo produces the Level2 as well as ModOne alone.
388 1.1 mrg
389 1.1 mrg What does it mean if the second modifier is the Lock? It means that in the
390 1.1 mrg first case (the Lock itself is included in the list of modifiers but combina-
391 1.1 mrg tions with this modifier aren't mentioned in the map statements) the internal
392 1.1 mrg capitalization rules will be applied to the symbol from the first level. But
393 1.1 mrg in the second case the capitalization will be applied to the symbol chosen
394 1.1 mrg accordingly to he first modifier - and this can be the symbol from the first
395 1.1 mrg as well as from the second level.
396 1.1 mrg
397 1.1 mrg Usually, all modifiers introduced in 'modifiers=<list of modifiers>' list are
398 1.1 mrg used for shift level calculation and then discarded. Sometimes this is not
399 1.1 mrg desirable. If you want to use a modifier for shift level calculation but you
400 1.1 mrg don't want to discard it, you may list in 'preserve[<combination of modi-
401 1.1 mrg fiers>]=<list of modifiers>'. That means, for a given combination all listed
402 1.1 mrg modifiers will be preserved. If the Lock modifier is preserved then the
403 1.1 mrg resulting symbol is passed to internal capitalization routine regardless
404 1.1 mrg whether it has been used for a shift level calculation or not.
405 1.1 mrg
406 1.1 mrg Any key type description can use both real and virtual modifiers. Since real
407 1.1 mrg modifiers always have standard names it is not necessary to explicitly
408 1.1 mrg declare them. Virtual modifiers can have arbitrary names and can be declared
409 1.1 mrg (prior using them) directly in key type definition:
410 1.1 mrg
411 1.1 mrg virtual_modifiers <comma-separated list of modifiers> ;
412 1.1 mrg
413 1.1 mrg as seen in for example basic, pc or mousekeys key type definitions.
414 1.1 mrg
415 1.1 mrg 4.3 Rules
416 1.1 mrg
417 1.1 mrg Once you are finished with your symbol map you need to add it to rules file.
418 1.1 mrg The rules file describes how all the five basic keycodes, types, compat, sym-
419 1.1 mrg bols and geometry components should be composed to give a sensible resulting
420 1.1 mrg xkb configuration.
421 1.1 mrg
422 1.1 mrg The main advantage of rules over formerly used keymaps is a possibility to
423 1.1 mrg simply parameterize (once) fixed patterns of configurations and thus to ele-
424 1.1 mrg gantly allow substitutions of various local configurations into predefined
425 1.1 mrg templates.
426 1.1 mrg
427 1.1 mrg A pattern in a rules file (often located in /usr/lib/X11/xkb/rules) can be
428 1.1 mrg parameterized with four other arguments: Model, Layout, Variant and Options.
429 1.1 mrg For most cases parameters model and layout should be sufficient for choosing
430 1.1 mrg a functional keyboard mapping.
431 1.1 mrg
432 1.1 mrg The rules file itself is composed of pattern lines and lines with rules. The
433 1.1 mrg pattern line starts with an exclamation mark ('!') and describes how will the
434 1.1 mrg xkb interpret the following lines (rules). A sample rules file looks like
435 1.1 mrg this:
436 1.1 mrg
437 1.1 mrg ! model = keycodes
438 1.1 mrg macintosh_old = macintosh
439 1.1 mrg ...
440 1.1 mrg * = xfree86
441 1.1 mrg
442 1.1 mrg ! model = symbols
443 1.1 mrg hp = +inet(%m)
444 1.1 mrg microsoftpro = +inet(%m)
445 1.1 mrg geniuscomfy = +inet(%m)
446 1.1 mrg
447 1.1 mrg ! model layout[1] = symbols
448 1.1 mrg macintosh us = macintosh/us%(v[1])
449 1.1 mrg * * = pc/pc(%m)+pc/%l[1]%(v[1])
450 1.1 mrg
451 1.1 mrg ! model layout[2] = symbols
452 1.1 mrg macintosh us = +macintosh/us[2]%(v[2]):2
453 1.1 mrg * * = +pc/%l[2]%(v[2]):2
454 1.1 mrg
455 1.1 mrg ! option = types
456 1.1 mrg caps:internal = +caps(internal)
457 1.1 mrg caps:internal_nocancel = +caps(internal_nocancel)
458 1.1 mrg
459 1.1 mrg Each rule defines what certain combination of values on the left side of
460 1.1 mrg equal sign ('=') results in. For example a (keyboard) model macintosh_old
461 1.1 mrg instructs xkb to take definitions of keycodes from file keycodes/macintosh
462 1.1 mrg while the rest of models (represented by a wild card '*') instructs it to
463 1.1 mrg take them from file keycodes/xfree86. The wild card represents all possible
464 1.1 mrg values on the left side which were not found in any of the previous rules.
465 1.1 mrg The more specialized (more complete) rules have higher precedence than gen-
466 1.1 mrg eral ones, i.e. the more general rules supply reasonable default values.
467 1.1 mrg
468 1.1 mrg As you can see some lines contain substitution parameters - the parameters
469 1.1 mrg preceded by the percent sign ('%'). The first alphabetical character after
470 1.1 mrg the percent sign expands to the value which has been found on the left side.
471 1.1 mrg For example +%l%(v) expands into +cz(bksl) if the respective values on the
472 1.1 mrg left side were cz layout in its bksl variant. More, if the layout resp. vari-
473 1.1 mrg ant parameter is followed by a pair of brackets ('[', ']') it means that xkb
474 1.1 mrg should place the layout resp. variant into specified xkb group. If the brack-
475 1.1 mrg ets are omitted the first group is the default value.
476 1.1 mrg
477 1.1 mrg So the second block of rules enhances symbol definitions for some particular
478 1.1 mrg keyboard models with extra keys (for internet, multimedia, ...) . Other mod-
479 1.1 mrg els are left intact. Similarly, the last block overrides some key type defi-
480 1.1 mrg nitions, so the common global behaviour ''shift cancels caps'' or ''shift
481 1.1 mrg doesn't cancel caps'' can be selected. The rest of rules produces special
482 1.1 mrg symbols for each variant us layout of macintosh keyboard and standard pc sym-
483 1.1 mrg bols in appropriate variants as a default.
484 1.1 mrg
485 1.1 mrg 4.4 Descriptive Files of Rules
486 1.1 mrg
487 1.1 mrg Now you just need to add a detailed description to <rules>.xml description
488 1.1 mrg file so the other users (and external programs which often parse this file)
489 1.1 mrg know what is your work about.
490 1.1 mrg
491 1.1 mrg 4.4.1 Old Descriptive Files
492 1.1 mrg
493 1.1 mrg The formerly used descriptive files were named <rules>.lst Its structure is
494 1.1 mrg very simple and quite self descriptive but such simplicity had also some cav-
495 1.1 mrg ities, for example there was no way how to describe local variants of layouts
496 1.1 mrg and there were problems with the localization of descriptions. To preserve
497 1.1 mrg compatibility with some older programs, new XML descriptive files can be con-
498 1.1 mrg verted to old format '.lst'.
499 1.1 mrg
500 1.1 mrg For each parameter of rules file should be described its meaning. For the
501 1.1 mrg rules file described above the .lst file could look like:
502 1.1 mrg
503 1.1 mrg ! model
504 1.1 mrg pc104 Generic 104-key PC
505 1.1 mrg microsoft Microsoft Natural
506 1.1 mrg pc98 PC-98xx Series
507 1.1 mrg macintosh Original Macintosh
508 1.1 mrg ...
509 1.1 mrg
510 1.1 mrg ! layout
511 1.1 mrg us U.S. English
512 1.1 mrg cz Czech
513 1.1 mrg de German
514 1.1 mrg ...
515 1.1 mrg
516 1.1 mrg ! option
517 1.1 mrg caps:internal uses internal capitalization. Shift cancels Caps
518 1.1 mrg caps:internal_nocancel uses internal capitalization. Shift doesn't cancel Caps
519 1.1 mrg
520 1.1 mrg And that should be it. Enjoy creating your own xkb mapping.
521 1.1 mrg
522 1.1 mrg Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/XKB-Enhancing.sgml,v 1.2 dawes Exp $
523 1.1 mrg
524 1.1 mrg
525 1.1 mrg $XFree86: xc/programs/xkbcomp/README.enhancing,v 1.5 2003/10/19 19:57:44 dawes Exp $
526