I have Elementary OS and there is problem if custom keyboard layout should be added, because currently the switchboard-plug-keyboard uses hardcoded layouts from data/layouts.txt
and does not scan /usr/share/X11/xkb/rules/evdev.xml
for new layouts, so you can't add your custom keyboard layout via UI, because it is not shown there.
I manually added my layout to layouts.txt, because the format of this file is simple and easy to understand.
data/layouts.txt (the last line i added)
#Czech:cz
Czech (UCW layout, accented letters only):ucw
Czech (US Dvorak with CZ UCW support):dvorak-ucw
Czech (qwerty):qwerty
Czech (qwerty, extended Backslash):qwerty_bksl
Czech (with <\|> key):bksl
Czech (programming):kblayout
And now i am able to add my layout via UI, but it does not work when activated.
This is what gsettings get org.gnome.desktop.input-sources sources
returns me:
[('xkb', 'cz'), ('xkb', 'us'), ('xkb', 'cz+kblayout')]
In part of /usr/share/X11/xkb/rules/evdev.xml below, you can see it should be properly configured, but the custom keyboard map not working:
<layout>
<configItem>
<name>cz</name>
<shortDescription>cs</shortDescription>
<description>Czech</description>
<languageList>
<iso639Id>cze</iso639Id>
</languageList>
</configItem>
<variantList>
<variant>
<configItem>
<name>bksl</name>
<description>Czech (with <\|> key)</description>
</configItem>
</variant>
<variant>
<configItem>
<name>qwerty</name>
<description>Czech (qwerty)</description>
</configItem>
</variant>
<variant>
<configItem>
<name>qwerty_bksl</name>
<description>Czech (qwerty, extended Backslash)</description>
</configItem>
</variant>
<variant>
<configItem>
<name>ucw</name>
<description>Czech (UCW layout, accented letters only)</description>
</configItem>
</variant>
<variant>
<configItem>
<name>dvorak-ucw</name>
<description>Czech (US Dvorak with CZ UCW support)</description>
</configItem>
</variant>
<variant>
<configItem>
<name>kblayout</name>
<description>Czech (programming)</description>
</configItem>
</variant>
</variantList>
</layout>
Interesting is that when i use setxkbmap kblayout
it works and even when i have activated kblayout via UI, in Keyboard layout chart i see keyboard map is properly set, but when i press some key, wrong character is given.