|
libxkbcommon
1.13.1
LibraryimplementingtheXKBspecificationforparsingkeyboarddescriptionsandhandlingkeyboardstate
|
This page describes how to add a custom keyboard layout or option so that it will be parsed by libxkbcommon.
An erroneous XKB configuration may make your keyboard unusable. Therefore it is advised to try custom configurations safely using xkbcli tools; see debugging for further details.
{html:2}
libxkbcommon searches the following paths for XKB configuration files:
$XDG_CONFIG_HOME/xkb/, or $HOME/.config/xkb/ if the $XDG_CONFIG_HOME environment variable is not defined. See the XDG Base Directory Specification for further details.$HOME/.xkb/ as a legacy alternative to the previous XDG option. xkb_keymap::xkb_keymap_new_from_names2() will look up those paths in order until the required data is found.<datadir>) path is available.Each directory should have one or more of the following subdirectories:
compatgeometry (libxkbcommon ignores this directory)keycodesrulessymbolstypesstruct xkb_rule_names. RMLVO names are merely lookup keys in the rules file provided by xkeyboard-config to map to the correct keycode, compat, geometry (ignored by libxkbcommon), symbols and types (KcCGST). The KcCGST data is the one used by XKB and libxkbcommon to map keys to actual symbols.us, variant dvorak and option terminate:ctrl_alt_bksp. Using the default rules file and model this maps into the following KcCGST components: Output of the command: xkbcli compile-keymap --kccgst --layout us --variant dvorak --options terminate:ctrl_alt_bksp
evdev) have a catch-all to map a layout, say foo, and a variant, say bar, into the bar section in the file <datadir>/X11/xkb/symbols/foo. This is sufficient to define a new keyboard layout. The example below defines the keyboard layout banana with an optional variant orange: Content of $XDG_CONFIG_HOME/xkb/symbols/banana
default section is loaded when no variant is given. The first example sections uses include to populate with a symbols list defined elsewhere (here: section basic from the file symbols/us, aka. the default US keyboard layout) and overrides parts of these symbols. The effect of this section is to swap the numbers and symbols in the top-most row (compared to the US layout) but otherwise use the US layout.orange variant uses the banana symbols and includes a different section to define the eurosign. It does not specifically override any symbols.xkb_symbols section works is out of scope for this document; see: The XKB keymap text format, V1 and V2.banana that should not clash with the system files in <datadir>/X11/xkb/symbols. Using the same file name than the system files is possible but may require special handling, see: Using system file names.evdev ruleset is hardcoded in many clients, the custom rules file must usually be named evdev. Content of $XDG_CONFIG_HOME/xkb/rules/evdev
include statement includes the system-provided evdev ruleset. This allows users to only override those options they need afterwards.custom:foo to the bar section in the symbols/custom file and the custom:baz option to the baz section in the symbols/other file. Note how the RMLVO option name may be different to the file or section name.custom:foo will always be applied before custom:baz and both options will always be applied after the system ones, even if the order is different in the RMLVO configuration passed to libxkbcommon (e.g. with xkbcli). See the related section in the rules documentation for further details. Content of $XDG_CONFIG_HOME/xkb/symbols/custom
Content of $XDG_CONFIG_HOME/xkb/symbols/other
custom:foo and/or custom:baz options.custom and other that should not clash with the system files in <datadir>/X11/xkb/symbols. Using the same file name than the system files is possible but may require special handling, see: Using system file names.<datadir>/X11/xkb/. It is possible to add a custom variant/option using the same file name than the system file, e.g. $XDG_CONFIG_HOME/xkb/symbols/us instead of $XDG_CONFIG_HOME/xkb/symbols/banana for the example in Adding a layout.broccoli layout variant: $XDG_CONFIG_HOME/xkb/symbols/us $XDG_CONFIG_HOME/xkb/symbols/us default before xkb_symbols in the custom file.Therefore is it highly recommended to not override the system sections and prefer creating proper independent variants.
%S to the included file. See the corresponding documentation.libxkbregistry as XKB lookup tool and does not work where clients parse the XML file directly.The above sections apply only to the data files and require that the user knows about the existence of the new entries. To make custom entries discoverable by the configuration tools (e.g. the GNOME Control Center), the new entries must also be added to the XML file that is parsed by libxkbregistry. In most cases, this is the evdev.xml file in the rules directory.
name <group>:<option_name>. shortDescription description name[Group1]. Content of $XDG_CONFIG_HOME/xkb/rules/evdev.xml
libxkbregistry ensures that the new layout and options are added to the system-provided layouts and options.<datadir>/X11/xkb/rules/xkb.dtd and the system-provided XML files <datadir>/X11/xkb/rules/*.xml.xkbcli tools. See debugging for further details.
1.8.10