Keyboard layout switching does not work properly

My system language is US English, I have attached some basic info below. I have set up German and Russian layouts, however upon login I obtain a US layout by default. Furthermore, when I switch e.g. to German, type some text in a window, then switch to another window, the layout gets reset to English. Also, when I type text in an Electron application, then delete a character, the layout gets reset to English. Does anybody else experience the same problem?

System specs: https://ibb.co/6tPGtQR

$ locale  
locale: Cannot set LC_MESSAGES to default locale: No such file or directory 
locale: Cannot set LC_ALL to default locale: No such file or directory 
LANG=en_DE.UTF-8 
LC_CTYPE=en_US.UTF-8 
LC_NUMERIC="en_DE.UTF-8" 
LC_TIME="en_DE.UTF-8" 
LC_COLLATE="en_DE.UTF-8" 
LC_MONETARY="en_DE.UTF-8" 
LC_MESSAGES="en_DE.UTF-8" 
LC_PAPER="en_DE.UTF-8" 
LC_NAME="en_DE.UTF-8" 
LC_ADDRESS="en_DE.UTF-8" 
LC_TELEPHONE="en_DE.UTF-8" 
LC_MEASUREMENT="en_DE.UTF-8" 
LC_IDENTIFICATION="en_DE.UTF-8" 
LC_ALL=



Login in what? Console?

And when you switch keyboard layout, how?

Do not assume that people are looking over your shoulder or are mind readers :wink:

The locale en_DE.UTF-8 doesn’t exist. I created one by running:

**erlangen:~ #** ln /usr/share/i18n/locales/de_DE /usr/share/i18n/locales/en_DE 
**erlangen:~ #** localedef -f UTF-8 -i en_DE de_DE.UTF-8 
**erlangen:~ #**

@karlmistelberger when I try your suggestion, I get


failed to access '/usr/share/i18n/locales/de_DE': No such file or directory

I assume I need to create a symbolic link in /usr/share/locale ? And if this works, should I report a bug to the Yast installer?

@hcvv I assumed that the KDE Plasma keyboard layout configuration tool only works when Wayland or (in my case) X11 are on. I get the problem regardless of whether I click or use keyboard shortcuts.

In your first post you nowhere even mentioned that this was related to a Desktop environment, let alone that it was using KDE. Let alone that you mentioned anything about differences when using Wayland or not.
I asked clarification because most here are not mind readers.

instead I linked a screenshot of the KDE Plasma help center. Will bear in mind to be more verbose in the future, thanks for the remark.

Yes, I see the link. Sorry for not looking there, but I mistrust such links. We have a pasting site vailable here: https://susepaste.org/

Sorry. I missed some details (I actually did that years ago;)) :

**erlangen:~ #** **zypper install glibc-i18ndata**         
Loading repository data... 
Reading installed packages... 
'glibc-i18ndata' is already installed. 
No update candidate for 'glibc-i18ndata-2.33-5.2.noarch'. The highest available version is already installed. 
Resolving package dependencies... 
Nothing to do. 
[FONT=monospace]**erlangen:~ #** **ln /usr/share/i18n/locales/de_DE /usr/share/i18n/locales/en_DE**            
[/FONT][FONT=monospace][FONT=monospace]**erlangen:~ #** **localedef -f UTF-8 -i en_DE /usr/lib/locale/en_DE.utf8**                          
**erlangen:~ #**[/FONT][/FONT]

After installing the package glibc-i18ndata, I managed to create the symbolic link as suggested. Unfortunately, this didn’t help. I tried to remove all layouts except German, logged out and in my KDE Plasma session and after a couple of hours I had 2 layouts, one US and one German. The US got included without my intervention.
Then I added a third layout. When I right-click on the flag symbol in the task bar, I can see that the first and last layout are both US (the last one says “with AltGr dead keys”), all the rest are in between. OTOH when I jump to the KDE configuration menu for layouts, I can only see the layouts I set up - which do not include US English.
Therefore I thought there must be some KDE deamon which overwrites the settings in the $HOME config path specific to KDE and I ignored the old config file:

$ mv ~/.kde4 ~/.kde4.old

But as soon as I customize the default settings to include any non-US layout, I get the same issues again. I will try a different Deskop Environment during the weekend to see whether or not this issue is KDE SC-specific.

Your Linux system uses US English as the default system language –

  • But, what is the Keyboard Layout of the Console Keyboard device attached to the system?

– The Laptop keyboard …
– The Keyboard device attached either to the Keyboard port of the Mainboard or, the 1st USB port of the Mainboard …

*=2]German?
*=2]Russian?
*=2]Something else?

Whichever Keyboard Layout the System Keyboard has, you set the System Keyboard layout in YaST –

Watch for variables LANG and LANGUAGE:

karl@3400G:~> echo $LANG 
de_DE.UTF-8 
karl@3400G:~> echo $LANGUAGE       
de:en_US 
karl@3400G:~>

Plasma uses:

**3400G:~ #** cat .config/plasma-localerc 
[Formats] 
LANG=en_DE.UTF-8 

[Translations] 
LANGUAGE=en 
**3400G:~ #**

Changes will take effect after logging out and logging in again. If the GUI doesn’t support your values use an editor such as nano instead while logged out from GUI. Your changes may be overwritten by the GUI when making changes while logged in.

System keyboard layout: https://susepaste.org/53110252
System language: https://susepaste.org/58968628

The system keyboard layout only works during the KDM login screen. Today I tried logging into GNOME, to a similar effect. The keyboard layout indicator claims ‘de’, but when I try typing some text I cannot enter any umlauts. At least in KDE Plasma the indicator corresponds to the currently set layout. So this has to be a bug in YasT or whichever freedesktop.org daemon is used by all desktop environments to configure layouts. Anyone knows the name? The system resets the layout to the system default language, even though the YasT setting ‘adapt keyboard layout to English’ is **not **ticked.

$ cat .config/plasma-localerc
[Formats]
LANG=en_DE.UTF-8
$ echo $LANG 
en_DE.UTF-8
$ [FONT=monospace]echo $LANGUAGE 
[/FONT]

When I keep the YasT setting for the system language but change the KDE Plasma language and hope to override the setting this way, the behavior does not change. In other words, the only way to use avoid a US layout is to deactivate layout switching and set all locales to German .

for the sake of completeness KDE layout settings:
https://susepaste.org/37567591

Systemd has a nice command for displaying system locale. Run that:

**erlangen:~ #** localectl              
   System Locale: LANG=de_DE.UTF-8 
       VC Keymap: de-latin1-nodeadkeys 
      X11 Layout: de 
       X11 Model: pc105 
     X11 Variant: nodeadkeys 
     X11 Options: terminate:ctrl_alt_bksp 
**erlangen:~ #**

User locale overrides system locale:

karl@erlangen:~> grep LANG .profile 
# in the variable RC_**LANG**. 
#export **LANG**=de_DE.UTF-8        # uncomment this line for German output 
#export **LANG**=fr_FR.UTF-8        # uncomment this line for French output 
#export **LANG**=es_ES.UTF-8        # uncomment this line for Spanish output 
karl@erlangen:~> 

Plasma settings:

karl@erlangen:~> cat .config/plasma-localerc  
[Formats] 
LANG=de_DE.UTF-8 

[Translations] 
LANGUAGE=de:en_US 
karl@erlangen:~> 

For smooth operation users need to check all three settings and make sure configured settings exist.

Out of the three suggested settings, only my contents of
.config/plasma-localerc

were different. I changed the settings to match yours, then logged out and in again. The effect was that KDE Plasma was in German, but the layouts were not affected.
I have another idea: maybe there exists a sysconfig setting which can configure system language and multiple keyboard layouts reliably. Will write back for the results.

I tested and it worked:

karl@3400G:~> cat .config/plasma-localerc             
[Formats] 
LANG=ru_RU.UTF-8 

[Translations] 
LANGUAGE=ru:de:en_US 
karl@3400G:~>

Check installation of KDE translations:

**3400G:~ #** zypper if plasma5-desktop-lang 
Loading repository data... 
Reading installed packages... 


Information for package plasma5-desktop-lang: 
--------------------------------------------- 
Repository     : Haupt-Repository (OSS) 
Name           : plasma5-desktop-lang 
Version        : 5.21.5-1.1 
Arch           : noarch 
Vendor         : openSUSE 
Installed Size : 12.7 MiB 
Installed      : Yes (automatically) 
Status         : up-to-date 
Source package : plasma5-desktop-5.21.5-1.1.src 
Summary        : Translations for package plasma5-desktop 
Description    :  
    Provides translations for the "plasma5-desktop" package. 

**3400G:~ #**

Everything the same except the package version of **plasma5-desktop-lang **is 5.18 and not 5.21. It seems I would need to install Tumbleweed and try it out there; I will be back with results, probably in a week again.

But, you have only ever shown us what the SOFTWARE settings are –

  • You have never described the physical HARDWARE
    keyboard device.

Please tell us which physical keyboard device (HARDWARE) is present on your system.

  • What is the physical (HARDWARE
    ) keyboard layout?

German keyboard (standard).
First of all, big thanks @karlmistelberger for the config options. Turns out I had 2 problems:

  1. https://github.com/atom/atom-keymap/issues/37 Keyboard layout switching is still buggy in Atom and this has nothing to do with openSUSE or KDE.
  2. I use fcitx-mozc, an input method for Japanese. By default, this input method obtains the system language and sets a default keyboard layout based on that information, not on configured keyboard layouts. In my case, since my system is in English, mozc automatically set up US keyboard layout whenever I don’t type in Japanese. This setting overrides the KDE keyboard layout configuration. I had to manually change to the standard German keyboard, now I can switch to any input language I want without problems.

You are welcome!

I use fcitx-mozc, an input method for Japanese. By default, this input method obtains the system language and sets a default keyboard layout based on that information, not on configured keyboard layouts. In my case, since my system is in English, mozc automatically set up US keyboard layout whenever I don’t type in Japanese. This setting overrides the KDE keyboard layout configuration.

In most cases users want to use their personal settings, not system settings. Any software should respect this.

I had to manually change to the standard German keyboard, now I can switch to any input language I want without problems.

Happy to hear you too now get intended behavior.:wink: