Ubuntu – How to persistently remap keys in Ubuntu 16.04

keyboardxmodmap

This is working for the current session:

costales@dev:~/Desktop$ xmodmap -e "keycode 166 = less"
costales@dev:~/Desktop$ xmodmap -e "keycode 167 = greater"

Then I created this config file:

costales@dev:~/Desktop$ cat ~/.Xmodmap 
keycode 166 = less
keycode 167 = greater
costales@dev:~/Desktop$ 

But it's not working after a reboot. How could I force the remap to survive reboot?

Best Answer

I've been using 16.04 for a little bit and it seems to use sddm as its desktop manager. It used to be LightDM and GDM before that. Both its predacessors are documented to load ~/.Xmodmap automatically but I can't find anything explicitly saying sddm does.

Therefore it may be 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.