Sometimes there comes a product with really dumbed down design choices: like Jelly Comb Bluetooth keyboard. The keyboard is small and has many features, but they decided that the top left key had to be Home
by default and Escape
when pressing the fn
modifier. If you want to use ubuntu window switching shortcut: Alt + Esc
you would need to press Alt + Esc + fn
which is way too many keys.
Finding the proper key
Before altering any file, you should verify that the key being pressed is what you think it is. To that end, go to your terminal and type:
xev
This will launch a nice event logging app, that will tell you which key you are pressing. Click on the tiny small window that pops up and then press the key you want to modify. They key being pressed should appear. For example for me it is:
root 0x1dd, subw 0x0, time 731172, (729,389), root:(1043,712),
state 0x10, keycode 180 (keysym 0xff1b, XF86HomePage), same_screen YES,
XKeysymToKeycode returns keycode: 9
XLookupString gives 1 bytes: (1b) ""
XmbLookupString gives 1 bytes: (1b) ""
XFilterEvent returns: False
The important bits here are: key 180
and symbol XF86HomePage
, this will let us find the appropriate file to modify.
After a few hours modifying wrong files mentioning
Escape
andHome
xev pointed me in the right direction, becauseHome
wasn't the actual name of the key I was pressing, xev indicated it was ratherXF86HomePage
.
So with the symbol you found, and also depending on the language you are using, you can pin point the proper file do:
cd /usr/share/X11/xkb/symbols
grep -R "XF86HomePage" .
Hopefully you will se the list of files affecting this symbol. The first line of grep output for me is:
./inet: key <I180> { [ XF86HomePage ] };
Notice also the key <I180>
and remember above xev
told os the key being pressed was 180
. It's not exactly the same, there is an I
before, but pretty close, so this may be it.
Final step
Now that we've located the file, lets modify it.
Of course this is not the official way to do things, you should never alter your system files like that, you should customize with the open tools that the system puts at your disposal, but I tried 20 tutos online and none of them worked, or required a PhD in X11 so, I decided to hack it out. Also since the Gnome Tweak Tool does not propose this remapping...
Let's do this
sudo vim ./inet
Then locate /I180
or /X86HomePage
(the one which will let you find the line faster). Then go and replace the symbol you don't want, with the one you want here I replace the symbol X86HomePage
, with my desired symbol Escape
:
key <I180> { [ Escape ] };
The names between curly and square brackets are the symbols in the files, so if you don't know how exactly the name of the symbol you would like, then you can browse the files for a clue.
Now restart your system, or some say you can use the shortcut: Alt + F2
to restart Gnome. I restarted my system.
Nodes
Failed attempts
I used dconf watch /
to figure out how Gnome Tweak Tool altered xkb options. It pointed out to org.gnome.desktop.input-sources xkb-options "['ctrl:capsctrl']"
. I figured it was a file named ctrl
in the /usr/share/X11/xkb/symbols
directory and the rule within named capsctrl
. Which I opened, and I tried to adapt it by copying that rule and adapting it to my needs, with no avail. And then let the system know I wanted to enable it: gsettings set org.gnome.desktop.input-sources xkb-options "['myswap:homeesc']"
but that made Gnome Tweak Tool settings stop applying, so I rolled back.
Conclusion
I spent too many hours to remap a simple key. Way too much friction.