Keyboard layout priority on KDE Plasma

Hi, I am using KDE Plasma on Manjaro ARM on an RPI 4. I have two keyboard layouts configured US and Italian (because I use the RPI with two different keyboards) and plasma nicely offers the possibility of switching between them by a layout selector on the system tray.

I have a problem in that KDE always starts up with the Italian layout selected even if I put the US one higher in the sorting order in the configuration window. As a confirmation US comes first in the .config/kxkbrc configuration file.This is weird because in another system I have with Ubuntu 20.04 and a much older Plasma, KDE respects the layout sorting order.

I suspect that the plasma edition on manjaro ignores the sorting order and picks as a default the keyboard layout that comes first in alphabetical order.

Anyone else experiencing this? Any hint on whether this may be a plasma regression or the effect of some bad interaction with other pieces of software in the manjaro distro (e.g. the manjaro keyboard selector).

I’m not sure what could be causing this, but in the meantime you can use a workaround by running a script on login that changes the keyboard to your desired language.

The command for X11 is:

setxkbmap us

For wayland I’m not sure what the command is (I think it depends on the DE actually)

1 Like

I experience exactly the same behaviour, but I can disprove the theory of alphabetical order. I have configured ch (Swiss German) and se (Swedish) whereas ch was installed first and should be my default. But on every reboot se is selected. It is also not depending on the order of LayoutList in the configuration.

Here’s my configuration:

❰philipp❙~❱✔≻ cat ~/.config/kxkbrc
[$Version]
update_info=kxkb_variants.upd:split-variants

[Layout]
DisplayNames=,
LayoutList=ch,se
LayoutLoopCount=-1
Model=pc101
ResetOldOptions=false
ShowFlag=false
ShowLabel=true
ShowLayoutIndicator=true
ShowSingle=false
SwitchMode=Global
Use=true
VariantList=,

Any idea how the default can be defined? Is it the desktop environment or the window manager which choses the keyboard layout? (I use SDDM with autologon)

I have x86-64 KDE

Operating System: Manjaro Linux
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
Kernel Version: 5.15.0-1-MANJARO (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-8250U CPU @ 1.60GHz
Memory: 31.1 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620

but I never meet such behavior for years.

my config is

cat ~/.config/kxkbrc                                                                                                                                                  ✔ 
[$Version]
update_info=kxkb_variants.upd:split-variants

[Layout]
DisplayNames=,
LayoutList=us,<edit: I hid my second layout but is it alphabetically above the "us">
LayoutLoopCount=-1
Model=pc86
Options=grp:alt_shift_toggle
ResetOldOptions=true
SwitchMode=Window
Use=true
VariantList=,

I never touch that file manually and did all via GUI: Meta / Super > System settings > Input devices > Keyboard > Layouts.

Try to re-initialize layouts again: remove all layouts, close the GUI settings window, add them again.
Try to play to add third/fourth layout: do they become by default now?

I have a solution which is working for me:

  1. Just delete the ~/.config/kxkbrc and reboot (maybe logoff is also sufficient)
  2. The kxkbrc contains now only one language, the one configured in /etc/X11/xorg.conf.d/00-keyboard.conf. Thus add the second language via plasma settings

My configuration looks now cleaner than before (I read that zoom respectively ibus mess up the content of the kxkbrc, but I don’t know if this is true)

❰philipp❙~❱✔≻ cat ~/.config/kxkbrc
[Layout]
DisplayNames=,
LayoutList=ch,se
LayoutLoopCount=-1
Model=pc86
ResetOldOptions=false
SwitchMode=Global
Use=true
VariantList=,
  1. Edit the file layout_memory.xml manually and change currentLayout
❰philipp❙~❱✔≻ cat ~/.local/share/kded5/keyboard/session/layout_memory.xml
<!DOCTYPE LayoutMap>
<LayoutMap version="1.0" SwitchMode="Global">
 <item currentLayout="ch"/>
</LayoutMap>

In my first post I wrote that I would expect KDE to save the last used keyboard layout. The name of the file implies to me that KDE is trying to do exactly that, but somehow doesn’t succeed.

@Philipp314
Glad to see that you solved the issue and posted your solution for all (including you in possible future).

Just delete the ~/.config/kxkbrc and reboot (maybe logoff is also sufficient)

That looks like you re-initialized the config from scratch.

Edit the file layout_memory.xml

Hm, editing XML manually? Are you sure that it is not a auto-generated file? I have a feeling that XML files could be re-written after some software starts or after getting some updates.

I suggest to try to find indirect (architecture data flow) method of editing it: to find what component is it related to, to change a mode/settings of that component via CLI/TUI or non-XML config, and somehow to try to re-generate that XML file.

Let’s see who is owns that file (which package’s usage and settings to learn for?). In my case:

$ pacman -Qo ~/.local/share/kded5/keyboard/session/layout_memory.xml
error: No package owns /home/m/.local/share/kded5/keyboard/session/layout_memory.xml

Oh, I do not have the file in my OS copy, it is empty directory:

$ ls -A1 ~/.local/share/kded5/keyboard/session
$

So in my case I can’t say you a package which it is originated from.

I forgot to post from where I had the solution from (I’m not allowed to post links → use your favourite search engine and search for [SOLVED] Wrong default keyboard layout in KDE in the arch forum)

Actually the file isn’t owned by any package also on my pc.

I’m pretty sure that the file is auto generated and as my backups shows it also had changed over time. Eg. I have a backup from june 29th and the file was last changed 13 days before. I have also experienced that from time to time it worked that ch was my default, but I was not able to associate this to a specific task I made.

1 Like

OK, so partial but the solution. Congrats!