Linux XKB files for custom ANSI and Colemak-DH ANSI layouts
As far as I know, when using Wayland one can just copy rules
and symbols
into the ~/.config/xkb/
directory and it should work
$ mkdir -p ~/.config/xkb
$
$ cd xkb-layouts/
$ cp -r rules symbols ~/.config/xkb/
$
$ tree ~/.config/xkb/
/home/user/.config/xkb/
├── rules
│ ├── evdev
│ └── evdev.xml
└── symbols
├── colemak_dh_ansi
├── custom_ansi
├── custom_colemak_dh_ansi
├── custom_rearrange
└── custom_symbols
2 directories, 7 files
Then log out and log in for keyboard layouts to be reloaded and choose a layout from your system's "Keyboard Settings > Layouts"
Copying files into ~/.config/xkb/
doesn't seem to work properly in X11, so we
need to directly edit files from /usr/share/X11/xkb/
for changes to take place
NOTE: It requires sudo
to edit files from /usr/share/X11/xkb/
and your
changes can occasionally be overwritten by system updates
So copy symbols
into /usr/share/X11/xkb/
$ cd xkb-layouts/
$ sudo cp -r symbols /usr/share/X11/xkb/
Then we need to manually edit rules/evdev.lst
and rules/evdev.xml
from
/usr/share/X11/xkb/
to add our custom layouts
# xed, vim or any other text editor
$ sudo xed /usr/share/X11/xkb/rules/evdev.lst
Find the ! layout
section in the file and add the following
colemak_dh_ansi Colemak-DH ANSI
custom_ansi (Custom) ANSI
custom_colemak_dh_ansi (Custom) Colemak-DH ANSI
$ sudo xed /usr/share/X11/xkb/rules/evdev.xml
Find the <layoutList>
section in the file and add the following
<layout>
<configItem>
<name>colemak_dh_ansi</name>
<shortDescription>CMK</shortDescription>
<description>Colemak-DH ANSI</description>
</configItem>
</layout>
<layout>
<configItem>
<name>custom_ansi</name>
<shortDescription>XA</shortDescription>
<description>(Custom) ANSI</description>
</configItem>
</layout>
<layout>
<configItem>
<name>custom_colemak_dh_ansi</name>
<shortDescription>XCA</shortDescription>
<description>(Custom) Colemak-DH ANSI</description>
</configItem>
</layout>
Then log out and log in for keyboard layouts to be reloaded and choose a layout from your system's "Keyboard Settings > Layouts"
In case you have added more than one keyboard layout in "Keyboard Settings > Layouts", your system can automatically enable the "Switching to another layout" shortcut in "Keyboard Settings > Layouts > Options"
That can cause your CapsLock not to function as Ctrl as
defined by symbols/custom_rearrange
. To fix that,
disable or change the "Switching to another layout" shortcut
Also, the order you list your keyboard layouts preference affects the way symbols are combined into groups, so keep your custom layouts at the top
I had previously mapped navigation keys on some alphanumeric keys using AltGr.
However, that requires a custom version of /usr/share/X11/xkb/types/iso9995
for it to preserve Shift, so we can select text while holding Shift, and also
takes space that could be used by international symbols
So I've removed that mapping and I'd recommend you to map navigation keys using your keyboard's Fn which is usually possible through a customization software developed by the manufacturer or open-source alternatives like QMK
See symbols/custom_colemak_dh_ansi
To see the resulting keyboard layout run xkbcomp -xkb $DISPLAY -
and to print
info about a specific layout run setxkbmap -layout layout-name-here -print
- https://who-t.blogspot.com/2020/02/user-specific-xkb-configuration-part-1.html
- https://who-t.blogspot.com/2020/07/user-specific-xkb-configuration-part-2.html
- https://who-t.blogspot.com/2020/08/user-specific-xkb-configuration-part-3.html
- https://who-t.blogspot.com/2020/09/user-specific-xkb-configuration-putting.html
- https://github.com/frgomes/hyena
- https://colemakmods.github.io/mod-dh/