Occasionally updates overwrite my manual edits to xkb/rules/evdev.xml

I use a custom keyboard layout that I’ve added in xkb, which requires an entry in evdev.xml before it’s available to most system utilities (I can set the keyboard layout with setxkbmap NAME without such an entry, but that doesn’t tend to stick for more than ten or twenty minutes). This is usually fine, but occasionally a system update overwrites evdev.xml and breaks my keyboard layout on the next reboot, requiring me to fight with my system and try to remember QWERTY enough to navigate to evdev.xml and add the required entry. This is additionally inconvenient given that I use i3wm, and changing the keyboard layout changes all of my window management controls.

Is there anything that can be done to avoid this issue? It’s rare enough (it’s happened two or three times since I switched to Manjaro a bit less than a year ago), but it would be very very lovely if it never happened again.


I can’t seem to find an equivalent config setting for pamac, and I can’t find an answer as to whether or not pamac ever makes use of pacman.conf.

I think it uses pacman’s config for that. :man_shrugging:

If you edit files in /usr tree - you will get frustrated as your changes will be overwritten without warning.

Instead you should create the rule locally - my guess would be /etc/X11/xorg.conf.d - to make it stick.


1 Like

Ah, that seems like it’s likely to be my solution. I’m not entirely sure I understand what exactly needs to be put in xorg.conf.d/, though; the page you link to is fairly minimal, and the XKB homepage it in turn links to has many broken links and I’m struggling to find answers for my specific use case.

No it doesn’t. :smiley:

You could save your layout as /usr/share/X11/xkb/symbols/custom, then select custom in the GUI, etc. This is exactly what it’s there for, no need to edit evdev.xml as it’s already defined.

Alternatively, you could use a systemd service, and a udev rule to keep applying it when necessary (most useful if you have multiple keyboards).

Then of course you could maintain a custom package of xkeyboard-config yourself. That’s only useful if you really do need to edit evdev.xml, etc, and want to use X. It’s probably easier to just make a script that edits the file for you and a pacman hook to run it when the package is updated.

If you used wayland, you could override it by putting your custom version of evdev.xml in /etc/xkb/rules/ or ~/.xkb/rules/

That’s what localectl is for.

sudo localectl set-x11-keymap gb

Obviously replace gb with the name of your layout.


I’m not sure I understand how localectl works. If I run that command once, will that properly set up the keyboard for availability in the future (eg by putting something useful in xorg.conf.d/) or do you have to run it every time the system boots? How does the resulting keyboard setting interact with fcitx etc?

Basically my goal here would be to have this keyboard permanently system-visible, without 1) getting into a bunch of automation stuff I probably don’t understand (custom packages, udev rules), 2) going to the effort to switch to Wayland, or 3) just using the ‘the custom one’ setup, as easy as that might be, because I find it kind of unpleasantly… patronising? bizarrely unextendable? … and even though I have one custom keyboard layout now I could easily see myself having more than one.

Exactly, it defines the system wide keyboard layout in xorgs config. This is permanent so you only need to run it once.

AFAIK, it just sets the layout anything else should be unaffected. There’s definitely one way to find out…

Sounds like a job for localectl.

If we’re talking about a single keyboard, you can switch between them using setxkbmap, or localectl, or assign them as different groups and switch with the group change key. The latter may require a logout and back in again, either way it’s better for permanent changes.

For multiple keyboards. You can set one system wide, but AFAIK the others will have to be applied using setxkbmap -device or xkbcomp -i (the latter is best used when you need to override inet(evdev) eg F13-24, or when you can’t figure out how to make a proper layout/experimenting).

I could write a script and a systemd service for you, but I’m not so good with udev rules (for external keyboards re-connecting), so you may have to figure that out yourself.

I’m not sure, but you might instead be able to edit the rules from xkeyboard-config to apply a different layout depending on the keyboard. But then you’d have the same problem of it being overwritten during an update.

Welp, I’ve run that localectl command! We’ll see what happens next time an update like this comes around :stuck_out_tongue:

Thank you!

1 Like