Bug 499182 - Keyboard layout English (US, international with AltGr dead keys) not persistent in Wayland (workaround available)
Summary: Keyboard layout English (US, international with AltGr dead keys) not persiste...
Status: RESOLVED DOWNSTREAM
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 6.1.5
Platform: Kubuntu Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-27 06:25 UTC by Jonathan Oliver Muñoz Valverde
Modified: 2025-01-27 19:40 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Oliver Muñoz Valverde 2025-01-27 06:25:16 UTC
SUMMARY
The keyboard layout English (US, international with AltGr dead keys) does not persist across sessions or system restarts in Wayland. While the default English (US) layout works correctly, switching to English (US, international with AltGr dead keys) results in the layout reverting to English (US) upon reboot/login. This issue also occurs even when selecting English (US, international with AltGr dead keys) during the initial system installation. It is unknown if this issue affects other keyboard layouts.

STEPS TO REPRODUCE
1. (Optional) Install Kubuntu 24.10 and select "English (US, international with AltGr dead keys)" during the installation process. Observe that upon first login (Wayland) the keyboard layout is "English (US)".
2. Open System Settings > Input Devices > Keyboard > Layouts.
3. Add or ensure the presence of the "English (US, international with AltGr dead keys)" layout.
4. Select "English (US, International with AltGr keys disabled)" as the active layout.
5. Click the "Apply" button. You can verify that the physical keyboard responds to the selected layout.
6. Restart the session or the system (Wayland).
7. Open System Settings > Input Devices > Keyboard > Layouts again.
8. Observe that the keyboard layout has reverted to "English (US)".


OBSERVED RESULT
Keyboard layout reverts to English (US) on reboot or login. Only on Wayland, on X11 the bug does not occur.

EXPECTED RESULT
The selected keyboard layout, specifically English (US, International with AltGr keys disabled), should persist across sessions and system reboots (on Wayland).

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 24.10
KDE Plasma Version: 6.1.5
KDE Frameworks Version: 6.6.0
Qt Version: 6.6.2 

ADDITIONAL INFORMATION
Workaround (Semi-Automated):

The goal was to create an executable script using a keyboard shortcut that would automatically switch to the English (US, International with AltGr keys disabled) layout on every reboot/login. The final script was designed to modify the LayoutList and VariantList lines within the kxkbrc configuration file (located in ~/.config/). However, simply modifying this file via the script does not immediately change the keyboard behavior. The changes are reflected in the System Settings > Input Devices > Keyboard > Layouts interface after exiting and re-navigating or restarting the application, but the new layout is not physically applied to the keyboard.

The discovered workaround involves the following steps:

1. Open System Configuration > Input Devices > Keyboard > Layouts before running the script (explained below).

2. Create and run a script with the following simplified code (which creates a backup of ~/.config/kxkbrc as ~/.config/kxkbrc.bak, only if it doesn't exist, and configures within ~/.config/kxkbrc: LayoutList to us and VariantList to altgr-intl). Or you can do it manually for testing purposes.

=======CODE:
#!/usr/bin/env bash

KXKBRC="$HOME/.config/kxkbrc"
BACKUP="$KXKBRC.bak"

# Create a backup if it doesn't exist
if [ ! -f "$BACKUP" ]; then
    cp "$KXKBRC" "$BACKUP"
    echo "Backup of kxkbrc created at $BACKUP"
fi

# Verify and modify LayoutList
if grep -q "LayoutList=us" "$KXKBRC"; then
    echo "LayoutList=us already exists in $KXKBRC"
else
    if grep -q "LayoutList=" "$KXKBRC"; then
      sed -i 's/LayoutList=.*/LayoutList=us/' "$KXKBRC"
      echo "LayoutList modified to LayoutList=us in $KXKBRC"
    else
      echo "LayoutList=us" >> "$KXKBRC"
      echo "LayoutList=us added to $KXKBRC"
    fi
fi

# Verify and modify VariantList
if grep -q "VariantList=altgr-intl" "$KXKBRC"; then
    echo "VariantList=altgr-intl already exists in $KXKBRC"
else
    if grep -q "VariantList=" "$KXKBRC"; then
      sed -i 's/VariantList=.*/VariantList=altgr-intl/' "$KXKBRC"
      echo "VariantList modified to VariantList=altgr-intl in $KXKBRC"
    else
      echo "VariantList=altgr-intl" >> "$KXKBRC"
      echo "VariantList=altgr-intl added to $KXKBRC"
    fi
fi

echo "Remember: Open System Settings > Input Devices > Keyboard > Layouts and make a minor change (like modifying a keyboard shortcut) to enable the 'Apply' button and for the keyboard change to take effect."

read -n 1 -s -r -p "Press Enter to continue..."
exit 0
=======END OF CODE

3. The changes are reflected in the System Settings > Input Devices > Keyboard > Layouts interface, but the new layout is not physically applied to the keyboard.

4. Make a minor change in the same "Layouts" settings page (like adding or removing any keyboard shortcut). This enables the "Apply" button.

5. Click on "Apply". The English (US, international with AltGr dead keys) layout is now correctly activated.

This workaround is semi-automatic because the script (executed for example with Meta+Alt+k), handles the configuration file modification, but requires a manual step in the system configuration to fully apply the change. However, it is simpler than manually adding the distribution on every reboot/login. This change is lost on reboot.

Additional Information:

This issue appears to be specific to Wayland, and more specifically, though not limited to, the English distribution (US, International with inactive AltGr keys). The issue has been investigated with the help of a large language model (Gemini). Different approaches were tested to try to trigger the switch without manual interaction, including:

 - Using kwin_x11 --replace
 - Using setxkbmap directly in XWayland
 - Using gsettings and dconf
 - Using xdotool (which was hindered by authorization issues with xprop in Wayland)

None of these methods were able to trigger the persistent application of the keyboard layout change.

The workaround of making a small change within the System Settings > Input Devices > Keyboard > Layouts interface was discovered, it was the only effective method to enable the script-modified English (US, International with AltGr keys disabled) layout. At least until the next reboot.

Emphasis on Gemini's role:

As stated in the description, Gemini, a large language model, played a crucial role in the investigation process. Gemini provided guidance, suggested different approaches, helped analyze the results of tests, and assisted in formulating this bug report.
Comment 1 Bug Janitor Service 2025-01-27 06:33:38 UTC
Thank you for the bug report!

However Plasma 6.1.5 is no longer eligible for support or maintenance from KDE; supported versions are 5.27. (LTS), and 6.2 (non-LTS) or newer. Please upgrade to a supported version as soon as your distribution makes it available to you. Plasma is a fast-moving project, and bugs in one version are often fixed in the next one.

If you need support for Plasma 6.1.5, please contact your distribution, who bears the responsibility of providing support for older releases that are no longer supported by KDE.

If you can reproduce the issue after upgrading to a supported version, feel free to re-open this bug report.
Comment 2 Jonathan Oliver Muñoz Valverde 2025-01-27 19:40:42 UTC
(In reply to Bug Janitor Service from comment #1)
> Thank you for the bug report!
> 
> However Plasma 6.1.5 is no longer eligible for support or maintenance from
> KDE; supported versions are 5.27. (LTS), and 6.2 (non-LTS) or newer. Please
> upgrade to a supported version as soon as your distribution makes it
> available to you. Plasma is a fast-moving project, and bugs in one version
> are often fixed in the next one.
> 
> If you need support for Plasma 6.1.5, please contact your distribution, who
> bears the responsibility of providing support for older releases that are no
> longer supported by KDE.
> 
> If you can reproduce the issue after upgrading to a supported version, feel
> free to re-open this bug report.

Thank you for your response.

I understand that Plasma 6.1.5 is no longer officially supported by KDE. However, Kubuntu 24.10, the distribution I am using, currently provides Plasma 6.1.5 as the default version. Upgrading to a supported Plasma version is not currently possible through the official Kubuntu repositories for this release.

The reported bug, the non-persistence of the "English (US, international with AltGr dead keys)" keyboard layout in Wayland, is present in this specific configuration. I understand that addressing bugs in unsupported versions is not a priority.

The reason for reporting this issue despite the unsupported status is twofold:

To document the issue: This report serves to document this specific problem with the "English (US, international with AltGr dead keys)" layout in Wayland under Plasma 6.1.5. This documentation may be helpful for other users experiencing the same issue and for future reference if the problem persists in later versions.
To explore potential solutions or workarounds: While a full fix might not be feasible for this specific version, documenting the issue and the discovered workaround (which involves a minor change in the Keyboard Layout settings to trigger the application of the layout) may provide insights for developers when addressing similar issues in supported versions.
I understand that the best solution is to upgrade to a supported version of Plasma when it becomes available through the official Kubuntu channels. I will retest the issue after upgrading and will reopen this bug report if the problem persists in a supported version.

Thank you for your time and consideration.