Permanently change one key mapping in keyboard layout


From Windows computers I’m used to write the apostrophe as AltGr+P on my localized keyboard (SLOVAK qwerty).
I achieved this by editing /usr/share/X11/xkb/symbols/sk and assigning apostrophe to the letter P.
This works.
But occasionally, after system update, this modified mapping is erased and reverted back to default.
How would I make this change more permanent?


Hi @flerken,


I understood the question wrong, sorry

I’m pretty sure this will help:

[root tip] [How To] Troubleshooting locale errors

Hope it does!

According to the accepted answer on this page:

…advisable to just force it to load with a new script. You just need to run xmodmap ~/.Xmodmap and you can do that a number of ways:

There are probably a few dozen other ways to manage this, essentially doing the same thing.

Hope this helps!

Edit #2:

Also look at :point_down:

and :point_down:

and :point_down:

Or any one of the myriad other options that Google tells you about when you ask it.

1 Like

That file is owned by a package so it will always be re-written when the package is updated.

You can copy the file and make your changes. If you call it sk_mine then use it like this setxkbmap sk_mine.

It’s temporary, see the link for making it permanent. Add to that, if the keyboard is external and is re-plugged then udev will override this, so you may need a udev rule to re-apply your custom map.

Xorg/Keyboard configuration - ArchWiki
udev - ArchWiki

You could instead dump the current config using xkbcomp $DISPLAY ~/.xkbmap, edit that and then reapply using xkbcomp ~/.xkbmap $DISPLAY. Also temporary, and also needs a udev rule for external keyboards.

Xorg/Keyboard configuration - ArchWiki

xmodmap works but is deprecated, and can’t do as much, though it should be fine for this. It’s definitely the best documented way/path of least resistance.

I haven’t used it much but AFAIK it would also need a udev rule for an external keyboard. However it may be automatically applied at login with some login managers (if you use a certain filename), with others it would need to be configured I think.

Thank you both, udev rules I don’t understand yet, meanwhile xmodmap works fine, I have it execute at login as a script.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.