Bug 485362 - Modifying kxkbrc configuration through the command line does not make changes take effect immediately
Summary: Modifying kxkbrc configuration through the command line does not make changes...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: input (other bugs)
Version First Reported In: 6.0.2
Platform: Arch Linux Linux
: NOR minor
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-11 08:50 UTC by Bojidar Marinov [:bojidar-bg]
Modified: 2025-06-03 14:56 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.5.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bojidar Marinov [:bojidar-bg] 2024-04-11 08:50:01 UTC
SUMMARY

Currently, changing `kxkbrc` through the command line via `kwriteconfig` results in no observable changes until the configuration is manually changed through the settings module.

Looking through the source code, I managed to get Kxkb/Kwin to reload the configuration through `dbus-send --session --type=signal --dest=org.kde.keyboard /Layouts org.kde.keyboard.reloadConfig`, but this was a pain to figure out. Ideally, KWin could listen for config changes to `kxkbrc` using `KConfigWatcher`, and eliminate the whole need for sending that `reloadConfig` signal; though I would be willing to settle for better documentation.

Why it matters? - Being able to change settings from the command line enables a larger variety of usecases, integrations, and extensions than KDE developers could have possibly planned out beforehand. This gives users more freedom and power than merely being able to modify the source code, as they can now modify the system's behavior without having to recompile it at all.

STEPS TO REPRODUCE

1. Run `cat .config/kxkbrc`, observe the current values of the configuration.
2. Run e.g., `kwriteconfig6 --file kxkbrc --group Layout --key Options caps:backspace`, which would make Caps an additional backspace.
3. Run `cat .config/kxkbrc`, observe that the configuration has been changed.

OBSERVED RESULT
Pressing CapsLock is still not as an additional backspace.
The configuration was not applied, and there is no documentation which would give a clue as to why.

EXPECTED RESULT

The configuration is applied as soon as it's changed through kwriteconfig6 OR there is an extra command that has to be run which is documented somewhere.
Pressing CapsLock functions as an additional backspace.

WORKAROUND

Run `dbus-send --session --type=signal --dest=org.kde.keyboard /Layouts org.kde.keyboard.reloadConfig` OR open the keyboard settings module and change some value back and forth to update the configuration

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2

ADDITIONAL INFORMATION

Vaguely related to bug 470470, as I wouldn't have ran into this issue if `setxkbmap` was working for my usecase (quickly switching the keyboard model between DreymaR's pc104awide model and the default pc104 model).
Comment 1 Nate Graham 2024-04-11 19:34:35 UTC
Using KConfigWatcher would make sense here, sure. If this is something you'd be interested in working on, please feel free!
Comment 2 Bug Janitor Service 2025-05-21 19:28:26 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/7655
Comment 3 Bug Janitor Service 2025-05-21 19:31:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/3012
Comment 4 Nate Graham 2025-06-03 14:56:02 UTC
Git commit c75d26ff98fc40004923e4e0f9bb441c3b970ec3 by Nate Graham, on behalf of Bojidar Marinov.
Committed on 03/06/2025 at 14:55.
Pushed by ngraham into branch 'master'.

keyboard_layout: use KConfigWatcher to listen for config changes

Currently, kwin uses a bespoke `org.kde.keyboard.reloadConfig` DBus
signal to reload the keyboard configuration. However, when automating
keyboard layout configuration changes, this ends up harming usability
a lot, requiring users to do [e.g.](https://askubuntu.com/a/1510142):
```bash
kwriteconfig6 --file kxkbrc --group Layout --key LayoutList en,de
dbus-send --session --type=signal --dest=org.kde.keyboard /Layouts org.kde.keyboard.reloadConfig
```

With this commit, keyboard layouts use `KConfigWatcher`, to instead
allow for the much simpler:
```bash
kwriteconfig6 --file kxkbrc --group Layout --key LayoutList en,de --notify
```

M  +24   -24   autotests/integration/keyboard_layout_test.cpp
M  +1    -0    autotests/integration/kwin_wayland_test.cpp
M  +9    -6    src/keyboard_layout.cpp
M  +4    -1    src/keyboard_layout.h

https://invent.kde.org/plasma/kwin/-/commit/c75d26ff98fc40004923e4e0f9bb441c3b970ec3
Comment 5 Nate Graham 2025-06-03 14:56:05 UTC
Git commit ead59561b7277c9d75066e6fb420e109beb40944 by Nate Graham, on behalf of Bojidar Marinov.
Committed on 03/06/2025 at 14:56.
Pushed by ngraham into branch 'master'.

kcms/keyboard: use KConfig::Notify instead of custom DBus signals for layout config changes

This is a companion commit to
https://invent.kde.org/plasma/kwin/-/merge_requests/7655.

It is a refactoring which drops the custom `org.kde.keyboard.reloadConfig`
DBus signal, replacing it with the more standard KConfig::Notify approach.
FIXED-IN: 6.5.0

M  +0    -1    kcms/keyboard/CMakeLists.txt
M  +0    -4    kcms/keyboard/kcm_keyboard.cpp
M  +3    -10   kcms/keyboard/keyboard_daemon.cpp
M  +2    -1    kcms/keyboard/keyboard_daemon.h
D  +0    -11   kcms/keyboard/keyboard_dbus.h
M  +1    -0    kcms/keyboard/keyboardsettings.kcfgc

https://invent.kde.org/plasma/plasma-desktop/-/commit/ead59561b7277c9d75066e6fb420e109beb40944