xmodmap
is obsolete; so indeed it should be done with the xkb
tools.
The swap you want seems not to be included by default with X11 files; so you have to write it yourself.
The page https://web.archive.org/web/20170825051821/http://madduck.net/docs/extending-xkb/ helped me to understand and find a way to do it.
Create a file ~/.xkb/keymap/mykbd
where you put the output of setxkbmap
, it will be your base keyboard definition; eg:
setxkbmap -print > ~/.xkb/keymap/mykbd
then, create a symbols file to define your key swapping, put it for example in ~/.xkb/symbols/myswap
there, put the following lines:
partial modifier_keys
xkb_symbols "swap_l_shift_ctrl" {
replace key <LCTL> { [ Shift_L ] };
replace key <LFSH> { [ Control_L ] };
};
then, edit the ~/.xkb/keymap/mykbd
file, and change the xkb_symbols
line to add
+myswap(swap_l_shift_ctrl)
finally, you can load it with xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykbd $DISPLAY
(you cannot use "~" for the -I
parameter).
It will probably spit a lot of warnings about undefined symbols for some rare keys, but you can ignore them (eg, redirect error to dave: 2> /dev/null
).
If you want to be able to easily swap between a normal and your inverted ctrl/shift one; just create under ~/.xkb/keymap/
another file, without the extra "myswap" option, and load it with xkbcomp
. You can make two small scripts to load them.
Let's try simplifying this a little.
I'm not aware of any symbols command keys.type=MULTI
, so I removed that line first.
I saved your file as keys
(minus that line) and ran xkbcomp -w 10 keys
. It reports:
Warning: No automatic type for 6 symbols
Using for the <TLDE> key (keycode 49)
Warning: Type "" is not defined
Using TWO_LEVEL for the <TLDE> key (keycode 49)
(and a lot more errors after that)
So, let's add a definition MULTI3
that mimics MULTI
but with 3 (6) levels:
type "MULTI3" {
modifiers = Shift+Mod3+Mod5;
map[Shift] = Level2;
map[Mod3] = Level3;
map[Shift+Mod3] = Level4;
map[Mod5] = Level5;
map[Shift+Mod5] = Level6;
level_name[Level1] = "Base";
level_name[Level2] = "Shift";
level_name[Level3] = "Alt";
level_name[Level4] = "Shift Alt";
level_name[Level5] = "Control";
level_name[Level6] = "Control Shift";
};
… and then assign it to TLDE
:
key <TLDE> {type="MULTI3", symbols=[grave, asciitilde, dead_grave, dead_tilde, dead_doublegrave, dead_belowtilde]};
OK, re-running xkbcomp -w 10 keys
confirms that this eliminates that error.
The same type of error affects 27 other keys … so, annotating them with the desired type, and/or creating new types to handle them, should eliminate those errors.
The case of having two groups defined (which, by the way, will interact in very unpleasant ways with most tools for picking a keyboard layout, eg in Gnome) in the same file, you will have to specify the symbols and types for each group. I've never tried this myself, but eg:
key <AD01> {type[group1]="NewTypeFor5Levels",
symbols[group1]=[q, Q, Greek_theta, Greek_THETA, U03D1],
type[group2]="TWO_LEVEL",
symbols[group2]=[Cyrillic_shorti, Cyrillic_SHORTI]};
// vartheta
key <AD02> {type[group1]="MULTI",
symbols[group1]=[w, W, a, A, b, B, c, C],
type[group2]="TWO_LEVEL",
symbols[group2]=[Cyrillic_tse, Cyrillic_TSE]};
Once the file can be compiled, you should have better success.
Best Answer
Try looking in /usr/share/X11/xkb/symbols as described on the setxkbmap man page. The options can be found in various files, try doing a
grep -rinH alts_toggle /usr/share/X11/xkb
./usr/share/X11/xkb/rules/xorg.xml
looks like a good choice.