SUMMARY kwin_wayland supports getting its xkb configuration from the environment variables XKB_DEFAULT_LAYOUT, and libxkbcommon's default include paths include $XDG_CONFIG_HOME/xkb. This should make it possible to load a custom keymap from ~/.config/xkb when launching kwin as a wayland compositor, even though kcm_keyboard only supports keymaps from the system-wide xkb library. However, on my system, kwin only looks in /usr/share/X11/xkb/ and /etc/xkb when loading the keymap, not in the other standard locations $HOME/.xkb and $XDG_CONFIG_HOME/xkb. STEPS TO REPRODUCE 1. put a custom keymap "mylayout" in $HOME/.config/xkb 2. create .config/plasma-workspace/env/setkeymap.sh containing export QT_LOGGING_RULES="kwin_*.debug=true" export XKB_LOG_VERBOSITY=10 export KWIN_XKB_DEFAULT_KEYMAP=yes export XKB_DEFAULT_LAYOUT=mylayout 3. launch plasma session OBSERVED RESULT The custom keymap is not used. The logs in .local/share/sddm/wayland-session.log confirm that libxkbcommon only searched /usr/share/X11/xkb/ and /etc/xkb. ADDITIONAL INFORMATION Possibly related to #388249? On a single-user machine, a possible workaround is to put one's custom keymaps in /etc/xkb.
libxkbcommon doesn't search for keymaps in .config/xkb because it uses secure_getenv. Since kwin_wayland plays with its nice capability, it has its effective capability set, so secure_getenv() won't work.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3402
Git commit 6e87fae7f72416e1108b00c7abdfd438dc713706 by Vlad Zahorodnii, on behalf of Weng Xuetian. Committed on 07/01/2023 at 11:35. Pushed by vladz into branch 'master'. Support XKB_CONTEXT_NO_SECURE_GETENV flag Since kwin play with CAP_SYS_NICE, secure_getenv will fail for xkbcommon to load user level xkbmap. This allows kwin to load config under ~/.config/xkb M +5 -0 CMakeLists.txt M +1 -0 src/config-kwin.h.cmake M +7 -1 src/xkb.cpp https://invent.kde.org/plasma/kwin/commit/6e87fae7f72416e1108b00c7abdfd438dc713706