I have made a custom xkb keymap that I am happy with, and I can load it with no issues using the following script
xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykeys $DISPLAY
and it works the way I want when I do it manually.
My problem is, I could not find any reasonable place to put it where it could be run on login and NOT get overwritten by the default configuration.
I have tried ~/.xinitrc, ~/.xsession, ~/.xsessionrc, ~/.xprofile, even ~/.config/autostart-scripts
Most of those scripts are run (checked with zenity), but it looks like something downstream apparently reverts back to the default configuration later, so that when my KDE plasma loads, the keys I remapped do not work until I run this script again manually.
How could I fix this?
UPDATE: I also noticed that I need to re-run the script after the laptop wakes up from sleep. Is there a way to make it more permanent without modifying the default config in /usr/share/X11/xkb ?
UPDATE 2: When the laptop wakes up from sleep, my keys are actually still working for about 2-3 seconds, and then suddenly stop (around the same time my bluetooth mouse reconnects: not sure whether this could be related or not) until I re-run the script.
UPDATE 3: Here's the contents of ~/.xkb/keymap/mykeys :
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+inet(evdev)+mysymbols(super_arrows)" };
xkb_geometry { include "pc(pc105)" };
};
and this is ~/.xkb/symbols/mysymbols:
partial modifier_keys
xkb_symbols "super_arrows" {
key <LEFT> {
type = "PC_SUPER_LEVEL2",
symbols[Group1] = [ Left, Home ],
actions[Group1] = [ NoAction(), RedirectKey(keycode=<HOME>, clearmods=Mod4) ]
};
key <RGHT> {
type = "PC_SUPER_LEVEL2",
symbols[Group1] = [ Right, End ],
actions[Group1] = [ NoAction(), RedirectKey(keycode=<END>, clearmods=Mod4) ]
};
key <UP> {
type = "PC_SUPER_LEVEL2",
symbols[Group1] = [ Up, Prior ],
actions[Group1] = [ NoAction(), RedirectKey(keycode=<PGUP>, clearmods=Mod4) ]
};
key <DOWN> {
type = "PC_SUPER_LEVEL2",
symbols[Group1] = [ Down, Next ],
actions[Group1] = [ NoAction(), RedirectKey(keycode=<PGDN>, clearmods=Mod4) ]
};
key <INS> {
symbols[Group1] = [ Print ],
actions[Group1] = [ RedirectKey(keycode=<PRSC>) ]
};
};
If I put include "mysymbols(super_arrows)" into /usr/share/X11/xkb/symbols/pc, and a symlink to mysymbols into /usr/share/X11/xkb/symbols, then my config becomes stable, but after re-login the redefined keys seize to auto-repeat (when pressed and held).
So my current process is: after login:
- launch
xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykeys $DISPLAYmanually - uncomment
include "mysymbols(super_arrows)"in/usr/share/X11/xkb/symbols/pcThen I can use the config normally until the next restart (re-login) :) Linux is really full of magic ! ;)