Keyboard definitions

From OLPC
Revision as of 00:00, 13 October 2006 by Mokurai (talk | contribs) (New article)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Notes provided by Pable Saratxaga of Mandriva Linux. Rewriting needed.

The X11 keyboard layouts are simple text files; in each file there
may be one or more layouts defined.

A layout can include some other one instead of redefining common things.
It has a name:

       name[Group1]="Foo";

that is used by some keyboard selection tools.
Then, it defines the needed keys.
For unicode keysyms, you have to add 0x1000000 to the unicode value.
For characters that can be defined with the literal keysyms (all those
in ascii and iso-8859-*) it is better to use them (eg, "space" instead
of "0x1000020").
individual keys are defined like this:

   key <CODE>  { [  normal,  shift, altgr, altgr_shift ] };

the CODE for a key is Axyy with x a letter to identify the row it is in:

E: the row with the digits
D: top row of letters
C: middle row
B: bottom row
A: the row of space bar

and yy is a number (in decimal notation) identifying the column:
01, 02, 03, 04, ...., 09, 10, 11, ...

some keys have special codes: LSGT, TLDE, BKSL, as they change their
position depending on the keyboard models.
and then all the special keys (space, control, function keys, numeric keypad,
etc) have special names too (but most often you don't need to redefine
them)

the best is to just take an existing layout file, and edit it to match
what you need.

To test it without restarting X, just launch: setxkbmap "xx"
or: setxkbmap "xx(yy)"
the first will load the default layout on the file "xx", the second
will load the layout "yy" of the file "xx".

If you need to load a non-latin layout; load also a latin one; otherwise
you are in big trouble :-) (unless you have some other way to change keyboards, such as a toolbar menu.)

For example: setxkbmap "fr,tifinagh(extended)" -option "grp:shifts_toggle"
loads both the French (fr) and tifinagh(extended) layouts;
and defines pressing both shift keys to toggle between those layouts.

It is possible to cheat a bit, by sending an unused unicode value,
and having the Compose file redefine that to the wanted string.
I have done it for arabic and tifinagh layouts; it works quite well.

It is not difficult to learn the file format by reading files in /etc/X11/xkb, including the various READMEs, but it is easier if you refer to the complete specification can be found at http://www.x-docs.org/XKB/XKBproto.pdf

A keyboard file usually has a two-letter name, from the IANA Language Subtag Registry, which replaces the obsolete ISO 639 standard for language codes.

When you are satisfied with a keyboard file, you can copy it to /etc/X11/xkb/symbols, where programs like KDE Control Center will pick it up automatically the next time you start X. (Look under Regional & Accessibility for Keyboard Layouts.) You can put any selection of keyboards on a toolbar menu.

We need somebody to comb through the keyboards available in the various Linux distributions, starting with Mandriva, and add them to the Laptop distribution. Anybody? I'll help.--Mokurai 00:00, 13 October 2006 (EDT)