gnome – Wrong Keyboard Layout Despite Correct OS Settings

gnomekeyboard-layoutmanjarosetxkbmap

I installed Manjaro 21.x (don't remember exact version) a few months back and I chose the Gnome flavor. As per usual I set up my OS to have two keyboard layouts (US and SE) and life was great. Then life became less great as I realised Gnome is not for me. So, I switched back to good old XFCE by simply installing XFCE using the package manager. Now, whenever I boot Linux (or log out and in again) my keyboard layout seem to be, in practice, US since everytime I write åäö it becomes [';. This happens anywhere in the OS.

I've tried to troubleshoot it but I have found nothing really. It seems the OS really believe I use the SE layout. For example the layout switcher in XFCE show SE:

enter image description here

Some output from interesting commands (they are the same regardless if I have the issue or worked around it):

➜ cat /etc/vconsole.conf                   
KEYMAP=sv-latin1
FONT=
FONT_MAP=

➜ localectl status                             
   System Locale: LANG=en_US.utf8
                  LC_TIME=sv_SE.utf8
                  LC_COLLATE=C
       VC Keymap: sv-latin1
      X11 Layout: se,us
     X11 Variant: ,

➜ setxkbmap -print -verbose 10                    
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     se,us
variant:    ,
options:    grp:win_space_toggle,terminate:ctrl_alt_bksp
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+se+us:2+inet(evdev)+group(win_space_toggle)+terminate(ctrl_alt_bksp)
geometry:   pc(pc105)
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "pc+se+us:2+inet(evdev)+group(win_space_toggle)+terminate(ctrl_alt_bksp)"   };
    xkb_geometry  { include "pc(pc105)" };
};

➜ cat /etc/X11/xorg.conf.d/00-keyboard.conf
# Written by systemd-localed(8), read by systemd-localed and Xorg. It's
# probably wise not to edit this file manually. Use localectl(1) to
# instruct systemd-localed to update it.
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "se,us"
        Option "XkbVariant" ","
EndSection

System info:

➜ cat /etc/os-release 
NAME="Manjaro Linux"
ID=manjaro
ID_LIKE=arch
BUILD_ID=rolling
PRETTY_NAME="Manjaro Linux"
ANSI_COLOR="32;1;24;144;200"
HOME_URL="https://manjaro.org/"
DOCUMENTATION_URL="https://wiki.manjaro.org/"
SUPPORT_URL="https://manjaro.org/"
BUG_REPORT_URL="https://bugs.manjaro.org/"
LOGO=manjarolinux

➜ gnome-shell --version
GNOME Shell 3.38.4

➜ xfce4-about --version
xfce4-about 4.16.0 (Xfce 4.16)

To work around this issue all I have to do is to change the layout by clicking SE in the above screenshot or by using the keyboard shortcut I've assigned. After I've done this the layout switcher still say SE, which is sort of expected I guess. Also, åäö now becomes the expected åäö.

Best Answer

Add setxkbmap <layout> to ~/.xinitrc.