I am using a ThinkPad laptop with Arch Linux, and I am looking into the possibilities of remapping my keyboard layout + modifiers.
What I want to do is similar to what you can do with the QMK firmware where you have multiple layers on your keyboard. But without being dependent on specific hardware.
I found some different ways to do it, example:
- xmodmap
- klfc
KLFC looks very simple and straight forward, yet I experienced some issues that I didn't understand, so I decided to dig a bit deeper.
Then I found out that (probably) the most basic way is to use xkb in X11 and then inherit from the layout which I want, and modify it to my needs.
I looked in the system files in /usr/share/X11/xkb
specifically in the symbols
directory where I have been looking a bit around in the different files, and I found some documentation from 1996 about the "xkb" API, but I haven't read it all. That's why I'm here asking for help.
I found that the symbols files are following a specific pattern.
key <AE01> { [ 1, exclam ] };
So the AE01 is the first key on the first row, and it is looking like something like a struct
in C with a list as an attribute.
The order of the list then depends on something I want to modify -- and this is my question.
The 1
on the first place in the list means that if I click the button without using any modifiers, then 1
will be printed to stdin, and the exclam
means that if I use the modifier key Shift
(or capslock
) then !
will be sent to stdin.
I want to define my own modifier keys, (locked and latched). Maybe 10 different modifier keys. Some of them (locking) like caps lock
and some of them (latching) like shift
or ctrl
, and I would like them to be independent (originals) so that I don't have to use something already defined.
I also want to have some of the (modifier keys) + (what they modify) to act together on a "deeper level". For example, I am using i3 and I use winKey
+ n(0..9) to switch between the desktops, then when I move the numbers under the letters, and use caps lock
+ (some letters) to get the numbers, then the shortcut in xkb conflicts with the shortcut in i3 and I don't get anything at all.
I guess that I will find out how to do all this If I just finish reading all the old documentation from 1994 for xkb, but I am hoping to find some nice clear tutorial, or hint which will get me started without having to take a whole xkb education. :)