Selected keyboard layout on KDE doesn't affect X11 keyboard layout

I’m using an application through Wine which needs to detect the current selected keyboard layout. The problem is that this functionality is not working properly, it always thinks I’m using the us layout no matter what I have selected.
After a bit of research I found that Wine uses X11’s keyboard layout query (aka setxkbmap -query). They use that to be as low level as possible. Running setxkbmap -query under KDE always shows the same result (first us and then my other keyboard layout) no matter what layout I choose through KDE. Is this even intended? I have no idea how the X11-KDE connection works, any help would be appreciated.

Thanks

Sounds like an issue with locale. I had this once too, but I forgot how I fixed it.
What Distri are you using and which Plasma version?

What is the output of:

cat ~/.config/plasma-localerc

and

locale -a

@Duha I have ArchLinux with Plasma 5.27.4

[nikolas@archlinux ~]$ cat ~/.config/plasma-localerc
[Formats]
LANG=en_US.UTF-8
LC_MEASUREMENT=el_GR.UTF-8
LC_MONETARY=el_GR.UTF-8
LC_NUMERIC=el_GR.UTF-8
LC_TIME=en_GB.UTF-8
[nikolas@archlinux ~]$ locale -a
C
C.UTF-8
el_GR.utf8
en_GB.utf8
en_US.utf8
POSIX

ArchLinux uses locale.gen for locales

[nikolas@archlinux ~]$ cat /etc/locale.gen | grep -v '^#'
el_GR.UTF-8 UTF-8
en_GB.UTF-8 UTF-8
en_US.UTF-8 UTF-8

The locale looks correct to me…

Pretty sure that’s the Problem. I had this issue with KDE & Arch as well. If I remember correctly after playing around with the locale settings it worked again (But I don’t remember what exactly I did).

Also see 4.1 Locale - ArchWiki

You could try to rename plasma-localerc, reboot and see if this fixes it.

Still same issue…

[nikolas@archlinux ~]$ setxkbmap -query
rules:      evdev
model:      pc104
layout:     us,gr
options:    terminate:ctrl_alt_bksp,grp:alt_shift_toggle

setxkbmap shows us,gr no matter what the selected keyboard layout is. I don’t think this has to do with locales…

It’s a problem with Wine after all. Wine can’t detect keyboard layouts reliably

Relevant PRs

Just to clarify, does only 1 app not work with wine or is it all wine apps/games?

You can change the order.

If de is at the top, setxkbmap -query gives: de,us. If i move us to the top it shows us,de.

€: to late

Odd, atleast for my wine applications layout changing works fine.