4

I just switched from xf86-input-evdev to xf86-input-libinput and it broke my keyboard layout – arrow keys with right alt, context menu key, delete key, numpad enter, etc. all weirdly swapped. libinput debug-events showed correct key, though. After checking Xorg.conf, I noticed the following line:

Option "XkbRules" "base"

After changing it to evdev, the keyboard worked correctly.

I found “The XKB Configuration Guide” which mentions the various rules but does not go into details about their difference.

What is the difference between the two layouts? Is it okay to use the evdev rules even with libinput?

3

tl;dr: On Linux, you should be using the evdev rules. As it says in the XKB guide you link:

On Linux systems, the evdev rules are most commonly used, on other systems the base rules are used.


The difference is largely historical. evdev is the modern Linux kernel input subsystem and did not exist when XKB was first written. If you look into the source code for xkeyboard-config, you'll find that both evdev and base rules are generated from (mostly) the same templates. Compare the generated files in your system XKB database with diff, though. You'll see many entries where the base rules loads inet symbols for specific keyboard models, while the evdev rules do away with most of those model-specific entries and load a more generalized set:

/usr/share/X11/xkb/rules/base:
[...]
! model         =       symbols
  a4techKB21    =       +inet(media_nav_common)
  asus_laptop   =       +inet(media_common)
  acer_tm_800   =       +inet(acer_laptop)
  benqx730      =       +inet(benqx)
  btc9116u      =       +inet(btc9019u)
  chromebook    =       +inet(chromebook)
  dellsk8125    =       +inet(dell)
// and about 50 more lines
// generated from xkeyboard-config/rules/base.m_s.part

/usr/share/X11/xkb/rules/evdev
[...]
! model         =       symbols
  $evdevkbds    =   +inet(evdev)+inet(%m)
  chromebook    =   +inet(evdev)+inet(chromebook)
  applealu_jis  =   +inet(evdev)+macintosh_vndr/jp(alujiskeys)
  *             =   +inet(evdev)
// ...that's all.
// generated from xkeyboard-config/rules/evdev.m_s.part

No really, that's the whole model-to-symbols section from the evdev rules, whereas the base version is 60-odd lines long. The evdev.m_s.part file is the source template for that section of the rules; it's a model-to-symbol mapping (the !model = symbol line at the start of that section; hence the m_s in the filename). The only other evdev-specific section of the rules comes from the evdev.m_k.part file, which is a model-to-keycodes mapping (the !model = keycodes section of the rules), and the differences there are similar.

For further details, consult the keycodes and symbols files referenced by those rules (especially /usr/share/X11/xkb/keycodes/evdev and /usr/share/X11/xkb/symbols/inet). You may be interested in this writeup of the XKB rules format.

  • I see the difference now, I still do not understand why base worked without libinput and does not with it, though. – Jan Tojnar Dec 28 '17 at 16:21
  • could be an edge case that libinput isn't handling properly yet. with full details of your configuration (exact XKB model, layout, variant, options, etc) one could do a full postmortem and determine an exact cause. consider filing a bug with xf86-input-libinput. – quixotic Dec 28 '17 at 23:40

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.