5

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 åäö.

2 Answers2

2

kleinbottle4's answer helped me find the solution.

TL;DR: I created ~/.Xkbmap and added my wanted layout se to it's contents.

After looking through the ~/.xinit file which read from the file suggested in their answer I began to understand the structure a little bit. But it took me a while and after a desperate attempt of running find /etc -type f -exec grep -Hn setxkbmap {} \; and going through the result:

/etc/lightdm/Xsession:27:        setxkbmap `cat "$file"`
/etc/gdm/Xsession:133:    setxkbmap `cat "$sysxkbmap"`
/etc/gdm/Xsession:138:    setxkbmap `cat "$userxkbmap"`
/etc/gdm/Xsession:149:           setxkbmap -symbols "$xkbsymbols"
/etc/gdm/Init/Default:71:SETXKBMAP=`gdmwhich setxkbmap`

I found out that the keyboard layout should probably be set in ~/.Xkbmap since both Xsession files in the find result have references to that file.

From /etc/gdm/Xsession we have:

userxkbmap="$HOME/.Xkbmap"
...
# merge in keymaps
if [ -f "$userxkbmap" ]; then
    setxkbmap `cat "$userxkbmap"`
    XKB_IN_USE=yes
fi

and in /etc/lightdm/Xsession we have:

# Load keymaps
for file in "/etc/X11/Xkbmap" "$HOME/.Xkbmap"; do
    if [ -f "$file" ]; then
        echo "Loading keymap: $file"
        setxkbmap `cat "$file"`
        XKB_IN_USE=yes
    fi
done

Now when I log out/in I get the correct layout enabled.

1

Add setxkbmap <layout> to ~/.xinitrc.

kleinbottle4
  • 185
  • 6
  • That did not work. As I understand it the .Xresources related files need to be in the form of "name.Class.resource: value". So, it seems it does not accept straight up commands like "setxkbmap se". I get "xrdb: colon missing on line 1, ignoring line" if I try to add the command to the file you mentioned. I did eventually find out how to solve this and your answer did help me find the way. I will post it separately. Thanks! – Anton Pettersson Apr 23 '21 at 17:26
  • Whoops, I meant ```~/.xinitrc```, but glad to know you've got it now – kleinbottle4 Apr 24 '21 at 12:57