I've been using the excellent colemak keyboard layout in place of
QWERTY for about 15 years now. Native colemak remaps CAPSLOCK to
Backspace, which is a neat idea. However, I like to use CAPSLOCK
as the Super key to interact with my window manager.
When I was still using i3, remapping CAPSLOCK to Super could be
done using xmodmap, a utility for Xorg, which is the underlying
display server that i3 uses:
xmodmap -e "keycode 66 = Super_L Super_L Super_L Super_L"A while ago, I switched from i3 to sway, which is not based on Xorg but uses the Wayland display protocol underneath. Consequently, modifying keyboard input using utilities designed for Xorg is no longer possible.
The input configuration options for sway are reasonably expressive (see sway-input(5)). The following config snippet almost does what I need:
input * {
xkb_layout "us"
xkb_variant "colemak"
xkb_options "caps:super"
}
It however turns out, that the xkb_options "caps:super"-line only
maps CAPSLOCK to Super if no other modifier is pressed,
otherwise it generates colemak's characteristic Backspace symbol
instead.
I created a file named custom in $HOME/.config/xkb/symbols/ that
includes the regular layout file and simply overrides the definition
for the CAPSLOCK key:
partial alphanumeric_keys
xkb_symbols "capsfix" {
include "us(colemak)"
name[Group1] = "English (Colemak capstosuper)";
key <CAPS> { [ Super_L, Super_L, Super_L, Super_L ] };
};In the sway config, I simply need to point to this modified layout instead
input * {
xkb_layout "custom"
xkb_variant "capsfix"
}