Keyboard layout is remembered from previous session

I have two keyboard layouts: us and ru. us is the first in a list in input devices. So when I reboot my PC or shutting down it and then turn on, when I enter to my desktop using X11 it remembers my last selected layout from previous session: if I rebooted PC with ru selected so ru will be selected on next boot, if ‘us’ was selected so ‘us’ will be selected on new boot. I want us selected by default on start of my desktop session.
It works like I want on Wayland and us is always selected on start no matter which layout was selected in previous session, but I want it works so on X11.
(SDDA is ok and has always english layout as it should be. I talk about already logged in user).

I could repeat a solution from Keyboard layout resets on reboot - #12 by fgiorgio and add setxkbmap us to autostart, but the command hide keyboard layout sign from the panel and I cannot switch layouts until go to Input Setting, make some changes and save it again.

After a little investigation I’ve found that my selected layout is saving in ~/.local/share/kded5/keyboard/session/layout_memory.xml this file is generated automatically, if I delete it will be created anyway but I don’t know what app create this file.
So how can I disable this layout memorizing?

Thank you in advance and sorry for my bad English :slight_smile: .

I opened a KDE bug report a while back for the opposite - I wanted the X11 behavior on Wayland. But anyway, from the response I received, it appears that what you want is not an exposed option:

On the other hand, on X11 we have no way to not remember last used layout

However, I came up with a login script that does what I want, and I think that it may work for you too. I have the following execute on login to my KDE session:

#! /bin/bash
sleep 5
qdbus org.kde.keyboard /Layouts setLayout 1

where setLayout # is a 0-indexed number of the keyboard mapping you have set in the Keyboard System Settings. If you want it to set to us, and us is the first in the list, use setLayout 0.

2 Likes

Thank you very much! This is exactly what I wanted. Works perfect for me.

1 Like