Bug 447203

Summary: startplasma-wayland overwrites $XKB_DEFAULT_*
Product: [Plasma] plasmashell Reporter: Marc Mezzarobba <marc+bugs>
Component: Startup processAssignee: Plasma Bugs List <plasma-bugs>
Status: CONFIRMED ---    
Severity: normal CC: kde, nate, plasma-bugs
Priority: NOR Keywords: wayland-only
Version: 5.23.4   
Target Milestone: 1.0   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Marc Mezzarobba 2021-12-18 20:00:04 UTC
SUMMARY

startplasma-wayland sets the environment variables XKB_DEFAULT_MODEL, XKB_DEFAULT_LAYOUT, XKB_DEFAULT_VARIANT, and XKB_DEFAULT_OPTIONS with values supplied by systemd-localed, possibly overwriting values set by a particular user with system-wide default.

STEPS TO REPRODUCE
1. export XKB_DEFAULT_LAYOUT=favorite_layout in .profile
2. launch plasma wayland session

OBSERVED RESULT

After session launch:

$echo $XKB_DEFAULT_LAYOUT
<system-wide default>

EXPECTED RESULT

$echo $XKB_DEFAULT_LAYOUT
favorite_layout

ADDITIONAL INFORMATION

It is possible to set these variables in ~/.config/plasma-workspace/env instead as a workaroud, but it took me a lot of time to realize that!
Comment 1 Nate Graham 2022-02-11 19:27:57 UTC
Would you like to submit a merge request to fix it?
Comment 2 Marc Mezzarobba 2022-02-15 08:25:20 UTC
(In reply to Nate Graham from comment #1)
> Would you like to submit a merge request to fix it?

I suppose I could try, but (a) I am not sure what the right thing to do would be (just skip importing the values from systemd-localed when any of the XKB_* envvars is set?), and (b) I have zero experience with KDE development. Where should I start?
Comment 3 Nate Graham 2022-02-15 15:21:24 UTC
This is pretty much what you'd need to change: https://invent.kde.org/plasma/plasma-workspace/-/blob/master/startkde/startplasma-wayland.cpp#L47

Inside queryAndSet, you'd check to see if the value of `var` is already set using `qgetenv()`; if it is, skip the `qputenv()` function call.