I wonder how I can remap some keys (especially modifier keys) in a way that will hopefully continue to work for the forseeable future, will probably work on different machines and preferrably use files in my home directory so that I can back it up during normal home backup.
I'm on Debian testing with i3 window manager. I've just found a way to accomplish the following:
- Map left windows key to Hyper_L
- Make Mod3 Hyper_L
- Let i3 use Mod3 as its mod-key.
I do this by executing the following in .xsession:
setxkbmap -layout us -option ctrl:swapcaps -option altwin:alt_super_win
xmodmap /home/eike/.config/xmodmaprc
xmodmap /home/eike/.config/xmodmaprc
and configuring i3 to use Mod3 in its config file.
The file ~/.config/xmodmaprc contains this:
keycode 133 = Hyper_L
remove mod4 = Hyper_L
add mod3 = Hyper_L
I run xmodmap twice because its first invocation yields
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 14
Current serial number in output stream: 14
The second invocation silently works as expected. (This also happens when run in an interactive shell).
My problem with this is the following:
- I would not like to use keycodes as they can differ from keyboard to keyboard.
- The solution seems extremely hacky and fragile, especially the double invocation to work around the error.
- People on the internet (best source ever...) claim that xmodmap is depreciated.
Can somebody help me?
A first step that would make me happier would be to use only xkbmap, as I have hopes that it is so widespread that it may be made compatible with wayland eventually.