So, base problem is I'm trying to invert my laptop's pgup/home and pgdn/end keys. Currently I have to use the function key to to access the home/end functionalities and I'd prefer it the other way.

So I found this answer: https://unix.stackexchange.com/a/188251/370442 Created a file like so (inside my $HOME):

└── keycodes
    └── local

with contents:

xkb_keycodes {
  <PGUP> = 110;
  <HOME> = 112;
  <PGDN> = 115;
  <END> = 117;

and execute command:

setxkbmap -print | sed -e '/xkb_keycodes/s/"[[:space:]]/+local&/' | xkbcomp -I${HOME}/.xkb - $DISPLAY

Which works. The keys are mapped exactly as I'd hope. However, every time I restart my computer (haven't tried specifically logging out and back in to see if it's different) the keys have returned to their original mappings. I was under the impression that this was a permanent command.

I then found this answer suggesting that gnome might be resetting my xkb settings: https://askubuntu.com/a/582498/550300 but changing the key suggested there had no noticeable effect on restart.

That's my backstory, here's my question: how do I make the above command permanent? I was trying to avoid adding something to my .bashrc because I thought there should've been a more permanent solution without directly overwriting the xkb files or executing a script on startup.


Hmm then you may:

  1. Create a new keyboard model file to replace pc105 default model (or any other model uses pc file) with the custom mapping. I don't remember if it should be added somewhere in indexes found in /usr/share/X11/xkb/rules/ like custom keyboard layouts.
  2. Set the new model in /etc/default/keyboard

Warning: Reboot is required, verify configuration well before doing it. Or at least prepare plan-b (on-screen keyboard, SSH login,..). If there is a mistake in syntax, it is possible you end up with non-functional keyboard input.

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.