gfx.xkb.parse

gfx.xkb

parse(text) -> keymap, err

Parse an xkb keymap

text is a resolved keymap: the text after xkb_keymap {, as a compositor sends it, with or without the trailing NUL. Returns nil and an error naming the line when the text does not parse, or when it holds an include, which only an unresolved keymap has.

keymap field or methoddescription
km:key(code, depressed, latched, locked, group)what the evdev code types under the four values of wl_keyboard.modifiers
km:mods(depressed, latched, locked)the named modifiers in force, the set km:key reports as mods
km:repeats(code)true when a held key repeats
km.groupsthe groups' names, km.groups[1] the first, as the keymap names them
km.unknownthe count of keysym names the tables do not hold; each reads as NoSymbol

km:key returns a table:

fielddescription
codethe evdev code
keysymthe keysym at the level in force; 0 for none
keythe key's name for a named keysym (ENTER, F1, KP_1, LEFT_SHIFT), else the character of the first level of the group
shiftedthe character of the second level, when it types one
textthe character the key types now, or nil
basethe key on a US layout: its character, or the key's name
modsa set of shift, caps_lock, ctrl, alt, super, hyper, meta, num_lock
group, levelthe group and the level in force, from 1

The group wraps: past the keymap's groups, then past the key's. The level is the one the group's type maps the modifiers in force to. text is nil for a control character, and while Ctrl is in force and the type does not take it: the caller encodes Ctrl. Alt leaves the text. Caps Lock changes a letter only through its type; xkbcommon's case change for a type without Lock is not made. Meta on the same real modifier as Alt is left out of mods, and Hyper on Super's.