You are not logged in.

#1 2023-03-06 13:41:09

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

[SOLVED] KDE/plasma resets my keyboard layout settings on every boot

I can use KDE System Settings to add an extra keyboard layout option by choosing Input Devices, then Layouts, then Add. In my case, I add a Thai keyboard option to the existing default US keyboard. After doing this, I can switch between layouts using ctrl-alt-k, and everything works fine.

The problem is that when I reboot, keyboard layout switching no longer works. When I go to the Layouts tab of Input Devices in System Settings, the Thai layout has disappeared from the list of currently available layouts, and I have to add it again if I want to type in Thai. As far as I can tell, this erasure of configuration settings on reboot only affects keyboard layouts, not other KDE settings.

It seems that the keyboard layout list is stored at ~/.config/kxkbrc, which currently reads:

[Layout]
DisplayNames=,
LayoutList=us,th
Use=true
VariantList=,

On reboot, however, the 'th' from the end of the LayoutList line disappears.

I'm at a loss as to how to try to fix this problem.

P.S. possibly relevant package versions:

plasma-desktop 5.27.2-1
wayland 1.21.0-2
fcitx5 5.0.21-1

Last edited by matthew_moppett (2023-03-11 14:56:09)

Offline

#2 2023-03-06 14:16:36

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

Reboot or re-login?
(Likely the latter)

=> Check the content of the file after the logout (w/o logging into KDE)

The brute force solution would be to set it immutable

sudo chattr +i ~/.config/kxkbrc # the file can now no longer be changed

Offline

#3 2023-03-06 14:45:19

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

seth wrote:

Reboot or re-login?
(Likely the latter)

Indeed, it is the latter.

The brute force solution that you suggested works (thanks!), although I might leave the thread marked unsolved for a day or two to see if someone comes up with something that addresses the root cause of the issue. Having an immutable config file could conceivably cause some weird and frustrating issues later down the track.

Last edited by matthew_moppett (2023-03-06 14:46:14)

Offline

#4 2023-03-06 14:50:01

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

Check your journal whether plasma somehow crashes out of the session.

Offline

#5 2023-03-07 15:33:40

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

I've looked at the output of

journalctl /usr/bin/plasmashell -f

while logging out (paste available here)
and also the entire systemd log:

journalctl -f 

-- paste available here

But I didn't notice anything particularly suspicious (not that I would know exactly what to look for).

I've also recorded the output of:

journalctl /usr/bin/plasmashell -f 

while logging in to KDE, and again I didn't notice anything amiss (paste available here).

It's worth noting that the kxkbrc file is reset during login, not during logout: it still has the Thai keyboard listed after logging out, only for this to disappear after I've logged in.

Offline

#6 2023-03-08 08:19:16

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

Well, plasma certainly completely crashes out of the session an then SDDM tries to generate XDG dirs in /$HOME, but since $HOME is empty it tries to use // - the usual mess of todays KDE roll
However, because of 

the kxkbrc file is reset during login, not during logout

that's likely not relevant, but you're running plama on wayland, are you? Does it also happen w/ an X11 session?

Offline

#7 2023-03-08 13:20:13

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

The kxkbrc file doesn't get clobbered if I use an X11 session.

Weirdly, plasma on X seems to use a different system for changing keyboard layouts (accessed through System Settings -> Regional Settings -> Keyboard -> Input Method), and I'm not sure where the configuration file for that setting is kept.

Offline

#8 2023-03-08 13:36:29

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

Should™ be kxkbrc as well?
See eg. https://bugs.kde.org/show_bug.cgi?id=433265

What led you to that conclusion?

Last edited by seth (2023-03-08 13:36:39)

Offline

#9 2023-03-09 14:55:57

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

It's kind of complicated.

This is what happens on my system: if I launch a Wayland session, I can change the keyboard layout via the keyboard shortcut specified on the System Settings → Input Devices → Layout pane. That keyboard shortcut  toggles between the layouts listed on that pane. The changes are reflected in the display of the “Keyboard Layout” widget in my system tray, and the layout list is written to and and read from the  ~/.config/kxkbrc file.

But I can also go to System Settings → Regional Settings → Input Method and add layouts there. There is no option to add a keyboard shortcut, but I there does seem to be a system tray widget that corresponds to this pane (the “Input Method” widget), and I can click on that and apparently get a menu to choose between layouts – but this has no effect on the way the system responds to keypresses. Changes made on this pane are not reflected in the ~/.config/kxkbrc file at all. On this pane there is also an option to add an input method “group”. If I do that, I can create a group containing only the Thai layout/input method, and I can use the “Input Method” system tray widget to switch between groups. But again, doing this has no effect on how keyboard input is processed.

On the other hand, if I launch an X11 session, the keyboard shortcut specified in System Settings → Input Devices → Layout only flashes a pop-up saying “English US”, but does not toggle between English and Thai as it does on Wayland. This happens even though the contents of System Settings → Input Devices → Layout (and of ~/.config/kxkbrc) has not changed at all. The “Keyboard Layout” widget also disappears from my system tray.

Clicking on the keyboard layout options shown in the “Input Method” widget (under the “Default” group) does not seem to have any effect, but using it to switch between groups (i.e. to the group containing only a Thai input method layout) actually does allow me to type in Thai.

To summarise: on Wayland, I can use the System Settings → Input Devices → Layout pane to add input methods and then use a keyboard shortcut/systray widget to change between them (but I need to make ~/.config/kxkbrc immutable afterwards). The System Settings → Regional Settings → Input Method pane doesn’t have any effect at all. On X11, on the other hand, System Settings → Input Devices → Layout doesn’t work at all, but System Settings → Regional Settings → Input Method does work (albeit in a non-straightforward way). Changes I make to the latter system are preserved between log-ins and are not reflected in the ~/.config/kxkbrc file.

Offline

#10 2023-03-10 08:08:28

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

System Settings → Regional Settings → Input Method

https://wiki.archlinux.org/title/Input_method
That's (probably) for fcitx5 et al, not the keyboard layout config - do you run that on your x11 session as well?

Offline

#11 2023-03-10 11:37:11

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

Yep, fcitx5 is running for both Wayland and X11 sessions. Thanks for clarifying the difference between input method and keyboard layout.

Offline

#12 2023-03-10 13:18:45

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

There seems to be a .local/share/kded5/keyboard/session/layout_memory.xml, https://bugs.kde.org/show_bug.cgi?id=435191

Offline

#13 2023-03-10 13:55:59

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

From what I can gather, that file is supposed to be for remembering what keyboard layout was active at logout, and returning to it at login (and the reported bug seemed to be about that not working properly).

For what it's worth, manually changing it from "us" to "th" and re-logging in (with ~/.config/kxkbrc set to immutable) doesn't seem to have any effect on the active layout for me.

Offline

#14 2023-03-10 14:43:56

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

As long as ~/.config/kxkbrc is immutable, anything in layout_memory.xml cannot have altering impact on it. Nothing can.

Offline

#15 2023-03-10 15:36:01

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

seth wrote:

As long as ~/.config/kxkbrc is immutable, anything in layout_memory.xml cannot have altering impact on it. Nothing can.

Yes, I realise that. I mean that since the file is immutable, the Thai keyboard layout remains available between relogins -- but nevertheless, changes to layout_memory.xml (e.g. substituting "th" for "us") do not seem to change the *active* layout on login.

But that doesn't really affect the problem one way or another, and I suspect that the bug report mentioning that file may not be all that relevant to my issue.

Offline

#16 2023-03-10 15:51:21

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

changes to layout_memory.xml (e.g. substituting "th" for "us") do not seem to change the *active* layout on login.

The working theory would be that layout_memory.xml rewrites ~/.config/kxkbrc and that causes the wrong layout.
So to test that you'd have to
1. track the layout in layout_memory.xml before and after the logout
2. check its impact on ~/.config/kxkbrc by making that NOT immutable and see whether the config of layout_memory.xml has any impact on kxkbrc with the login.

Offline

#17 2023-03-11 04:29:26

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

I did a test as you suggested.

With both US and Thai keyboard layouts added and working, I checked the contents of layout_memory.xml. Oddly, it contained the line <item currentLayout="th"/>, even though the current active layout was US.

I logged out, checked again that the <item currentLayout="th"/> was still there (it was), and logged in again. As usual, the Thai layout was not working and the "th" entry had disappeared from ~/.config/kxkbrc.

I then re-added the Thai keyboard layout, checked that ~/.config/kxkbrc had the line "LayoutList=us,th", and changed layout_memory.xml so that it read <item currentLayout="us"/>. I then logged out, checked that the two files had not changed, and logged in again. Once again, the usual had happened: no Thai keyboard layout available, and ~/.config/kxkbrc had reverted to "LayoutList=us".

So it doesn't look like the layout_memory.xml file has an effect on whatever is happening to ~/.config/kxkbrc.

Offline

#18 2023-03-11 07:34:52

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

So it doesn't look like the layout_memory.xml file has an effect on whatever is happening to ~/.config/kxkbrc.

Nope.
You'll have to file an upstream bug (which this obviously is) cause Idk enough about modern KDE for better guesses where this falls apart.

Well, in a very twisted way:

localectl

If you've a localectl generated xorg configlet for the keyboard layout and the wayland, but not X11 version of plasma uses that to trash the user specific keyboard config…

Offline

#19 2023-03-11 13:46:00

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

OK, then. Thanks a lot for your help.

Offline

#20 2023-11-02 23:39:02

renyuneyun
Member
Registered: 2017-01-21
Posts: 9

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

Hi. I'm wondering if @matthew_moppett filed a bug report to upstream?
I'm encountering the same issue, and just realised it is a bug. Searching on bug.kde.org has some results, but none seems to be matthew's.

- https://bugs.kde.org/show_bug.cgi?id=470470
- https://bugs.kde.org/show_bug.cgi?id=341314

In particular, the second one seems to indicate a potential cause: the IME (fcitx, in my case). It somehow sets the keyboard layout...

Offline

#21 2023-11-03 02:42:36

matthew_moppett
Member
Registered: 2022-01-02
Posts: 16

Re: [SOLVED] KDE/plasma resets my keyboard layout settings on every boot

> Hi. I'm wondering if @matthew_moppett filed a bug report to upstream?

No, I'm afraid I didn't, although I suppose I should have.

Offline

Board footer

Powered by FluxBB