Bug 489975 - Keyboard layout selection has wrong values for variants
Summary: Keyboard layout selection has wrong values for variants
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_keyboard (show other bugs)
Version: 6.1.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-09 12:39 UTC by ansalexrichter
Modified: 2024-09-12 08:05 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.2.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ansalexrichter 2024-07-09 12:39:32 UTC
SUMMARY
Since 6.1, selecting Keyboard layout variants in settings seemingly doesn't apply the correct settings in the background. In multiple cases, it just maps to "BQN", which doesn't work, and is at least breaking the Keyboard Layout Switcher in the taskbar and previewing the layout itself.

STEPS TO REPRODUCE
Break the layout preview:
1. Open Keyboard Layouts in Settings
2. Search for "German, Swedish and Finnish" and click preview

Break the keyboard layout switcher:
1. Open Keyboard Layouts in Settings
2. Select two languages without variants to make sure the keyboard layout switcher pops up in the taskbar (For example, English (US) and German

OBSERVED RESULT
First example:
The Keyboard preview fails to load with the following error:

Keycodes above 256 (e.g. <I256>) are not supported by X and are ignored
Error:            No Symbols named "de_se_fi" in the include file "bqn"
                  Exiting
                  Abandoning symbols file "(null)"

Second example:
The keyboard layout switcher stops displaying in the taskbar.


EXPECTED RESULT
First example: The keyboard previews correctly.
Second example: I can switch to the selected Keyboard Layout with the variant.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: bazzite-stable (also reproduced on NixOS)
(available in About System)
KDE Plasma Version: 6.1.1
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
I found this related Discuss post having the same issue with cz_sk_de: https://discuss.kde.org/t/cannot-select-keyboard-layout/18313

Another person was able to reproduce this issue when asking, and suggested a workaround that avoids the issue:
1. Go to ~/.config/kxkbrc
2. In [Layout], manually add your variant (this config works for me):
[Layout]
DisplayNames=,
LayoutList=de,us
ResetOldOptions=true
Use=true
VariantList=,de_se_fi
Comment 1 silvia-cor 2024-07-30 05:59:10 UTC
The exact same happened to me with English (US, international AltGr Unicode combining) on a new installation of CachyOS with KDE Plasma 6.1. 
I can confirm that the suggested workaround solves it, and the keyboard layout switcher in the taskbar behaves as expected as well.
Comment 2 Ismael Asensio 2024-09-02 19:24:08 UTC
Can confirm the bug.

The issue is the selector not assigning internally the "exotic variants" (those in evdev.extras.xml) to the correct layout, but to the BQN layout  (which has no variants) instead, an so the setting fails since it is a non-supported combination.

The workaround assigns the variant to the right layout ("us" in this case) as it should be, so everything works. 

Thanks for filing a bug report! Otherwise it could have easily got forgotten in discuss
Comment 3 Bug Janitor Service 2024-09-02 22:34:20 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/2496
Comment 4 Ismael Asensio 2024-09-11 22:07:59 UTC
Git commit d9ee7cbbdd3fdec3a71ec847aaf00d6a36dbda6b by Ismael Asensio.
Committed on 11/09/2024 at 21:54.
Pushed by iasensio into branch 'master'.

kcms/keyboard: Fix assigning variants to wrong layouts for "extra" rules

When processing the xkb_rules files, we cannot assume that the layouts
and their corresponding variants will always come in order. Instead
find the layout by name before assigning the variant.

This fixes the layout/variant matches defined in `*.extras.xml`, which
are merged later, and provide new variants to layouts that were already
FIXED-IN: 6.2

M  +16   -12   kcms/keyboard/xkb_rules.cpp

https://invent.kde.org/plasma/plasma-desktop/-/commit/d9ee7cbbdd3fdec3a71ec847aaf00d6a36dbda6b