https://bugs.kde.org/show_bug.cgi?id=499182

            Bug ID: 499182
           Summary: Keyboard layout English (US, international with AltGr
                    dead keys) not persistent in Wayland (workaround
                    available)
    Classification: Plasma
           Product: plasmashell
           Version: 6.1.5
          Platform: Kubuntu
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: plasma-b...@kde.org
          Reporter: jonathan.muno...@gmail.com
                CC: k...@davidedmundson.co.uk
  Target Milestone: 1.0

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.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to