3

In a kind of "Linux from scratch" environment I have the problem that xkbcomp fails on startup of X. I found that I even can't compile keymaps on my standard Ubuntu machine:

xkbcomp -w 10 -R/usr/share/X11/xkb -xkm rules/evdev dummy.km

This results in the error:

Warning: Changing root directory to "/usr/share/X11/xkb"
syntax error: line 16 of rules/evdev
last scanned symbol is:
Errors encountered in rules/evdev; not compiled.

How is xkbcomp supposed to be used?

1
  • Sorry, the error message would have been helpful - added now.
    – Martin
    Jun 13, 2018 at 9:16

1 Answer 1

6

/usr/share/X11/xkb/rules/evdev contains a specification of rules. Rules tell XKB how to build keymaps from part, they don't specify a particular keymap. The input of xkbcomp needs to be a keymap.

The easiest way to figure out what the input should be is to read the man page (haha no) read the official documentation (as if) read the misleadingly named Unreliable guide (which is so good it's linked on the semi-official X.org wiki, but while it does have the information it's not actually stated that this is the input for xkbcomp) errr, ask on the Internet? Oh, you just did that.

Well, xkbcomp works both ways. So if you just ask it to decompile the keymap from your display, you'll see some acceptable input.

xkbcomp :0 - | less

The syntax is:

xkb_keymap {
  xkb_keycodes { … };
  xkb_types    { … };
  xkb_compat   { … };
  xkb_symbols  { … };
  xkb_geometry { … };
}

The content of the braces after xkb_xxx are things that go into files in the directories /usr/share/X11/xkb/xxx. You can use an include statement to tell xkbcomp to read existing files. Note that you need a single include directive with + between file names. Some files contain multiple xkb_xxx directives, pass the name of the one you want in parentheses. For example, to use the US layout with Compose on Menu, use

xkb_symbols { include "us+compose(menu)" }

You can ask setxkbmap to produce acceptable input for xkbcomp. Pass the -print option to see the output rather than push the keymap to the server. With setxkbmap, pass -compat, -geometry, -keycodes and -types to set the corresponding xkb_xxx, and -layout for xkb_symbols.

setxkbmap -layout "us+compose(menu)" -print

Actually, I lied by omission above, there's an easier way: the information is on the Arch wiki. If you like understanding how to configure your system, the Arch wiki is an excellent resource, whether you're using Arch Linux or not.

2
  • -layout "us,compose(menu)" appears to result in the compose(menu) option used for the Group 2 layout; this is probably not what you want. (this syntax is used to specify up to 4 languages to be switched between, so -layout us,de,ru,se or similar.) you want -layout us -option compose:menu. compare your version's +compose(menu):2 with the -option's +compose(menu).
    – quixotic
    Jun 14, 2018 at 20:35
  • @quixotic Oh, right, thanks. I simiplified this from my own configuration, which works for me, but I actually had + in there, not ,. Fixed. Jun 14, 2018 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.