The answers by quixotic, are complete, functional and probably what you should normally do. However, if you do not want to copy and modify the rules
files, for whatever reason, here is an alternative solution.
In this case, we will be loading an "xkb keymap file", directly using xkbcomp
.
First, create whatever custom layout or option you want, say in file ~/.config/xkb/symbols/option_file
with contents:
partial hidden modifier_keys
xkb_symbols "new_option_1" {
[...]
};
Next, dump your current layout, using setxkbmap -print > ~/.config/xkb/keymap/my_layout
. (Note that this does not, necessarily, have to be in the same directory hierarchy as the symbols
file above (or any other files you add), as we will be specifying the path to it explicitly.) This will be something of the form of:
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+inet(evdev)" };
xkb_geometry { include "pc(pc105)" };
};
To enable your new option, edit the dumped layout, by adding +option_file(new_option_1)
to the xkb_symbols
line, so our example would have become:
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+inet(evdev)+option_file(new_option_1)" };
xkb_geometry { include "pc(pc105)" };
};
Finally, load the new keymap with: xkbcomp -I$HOME/.config/xkb ~/.config/xkb/keymap/my_layout $DISPLAY
.
References:
http://madduck.net/docs/extending-xkb/
https://www.vinc17.net/unix/xkb.en.html