Unable to permanently change X11 keyboard settings with localectl

Hi.

I’m a new user of EndeavorOS with i3wm. My keyboard is currently set to a US layout but I also want an Icelandic layout.

I first tested if I could change the layout for a particular session using the setxkbmap command:

setxkbmap -layout "us,is" -option grp:alt_shift_toggle 

This works just fine. Next, I use the localectl command to change it permanently:

localectl --no-convert set-x11-keymap us,is pc105 ""  grp:alt_shift_toggle

After running the command above, the output of localectl is:

   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us,is
       X11 Model: pc105
     X11 Options: grp:alt_shift_toggle

I then reboot my computer. Once I login, the keyboard is set to us, which is what I want, but I can’t toggle between us and is. I’ve tried to fix this myself by googling but to no avail. I would appreciate any help.

Does this mean what i think it means?

Note that setxkbmap adds options specified in the command line to the options
               that  were  set before (as saved in root window properties). If you want to replace all previously specified options,
               use the -option flag with an empty argument first.

What’s the output of: cat /etc/X11/xorg.conf.d/00-keyboard.conf ?

It is:

# 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" "us,is"
        Option "XkbModel" "pc105"
        Option "XkbOptions" "grp:alt_shift_toggle"
EndSection
1 Like

Thanks!

It looks normal to me. I am not sure why the setting won’t survive a reboot. Please wait for other forummates to have a look.

Also welcome to EnOS’ forum @tjonmundsson!

:hotsprings:

I was assuming that the above meant it would revert back if you didn’t have the empty argument with the option flag? I know nothing! I just ask?

For what it’s worth I did run:

localectl --no-convert set-x11-keymap us pc105 "" ""

to clear options. Rebooted and then reran:

localectl --no-convert set-x11-keymap us,is pc105 "" grp:alt_shift_toggle

Rebooted again. Didn’t work, unfortunately.

how you toggle between them?

By pressing alt and shift. Tried all permutations of left, right alt and shift.

Ok. Did this worked sometime ago?

Because i can imagine that i3wm intercept this.

@tjonmundsson

This any help? It talks about keyboard layouts. 4.3

Not that I know. This is my first time using EOS and i3wm. I changed grp:alt_shift_toggle to grp:caps_toggle without any success so the problem is not restricted to alt/shift.

@richlinux Thanks for the link but unfortunately no dice.

Yes. But like i understand it, the keyboard layout switching, is handled by X11 self.

How do you start i3wm? With a login manager?

You could disable that temporarly, than start from TTY a X11 Session without anything, only with xterm, and test if it is working. If yes, it is a problem with i3wm than.

1 Like

@tjonmundsson

" https://wiki.archlinux.org/title/Xorg/Keyboard_configuration#Setting_keyboard_layout "

Using X configuration files
Note: xorg.conf is parsed by the X server at start-up. To apply changes, restart X.
The syntax of X configuration files is explained in Xorg#Configuration. This method creates system-wide configuration which is persistent across reboots.

Here is an example:

/etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "cz,us"
        Option "XkbModel" "pc104"
        Option "XkbVariant" ",dvorak"
        Option "XkbOptions" "grp:win_space_toggle"
EndSection
Using localectl
For convenience, the tool localectl may be used instead of manually editing X configuration files. It will save the configuration in /etc/X11/xorg.conf.d/00-keyboard.conf, this file should not be manually edited, because localectl will overwrite the changes on next start.

The usage is as follows:

# localectl [--no-convert] set-x11-keymap layout [model [variant [options]]]
To set a model, variant or options, all preceding fields need to be specified, but the preceding fields can be skipped by passing an empty string with "". Unless the --no-convert option is passed, the specified keymap is also converted to the closest matching console keymap and applied to the console configuration in vconsole.conf. See localectl(1) for more information.

To create a /etc/X11/xorg.conf.d/00-keyboard.conf like the above:

# localectl --no-convert set-x11-keymap cz,us pc104 ,dvorak grp:win_space_toggle

" this file should not be manually edited, because localectl will overwrite the changes on next start. "

Thanks for the link. I tried multiple versions of what is suggested but none work. Currently it is set to:

exec --no-startup-id setxkbmap -model pc105 -layout 'us,is' -variant ,, -option 'grp:alt_shift_toggle'

@lunainvictum I’ll try what you suggest later and get back to this thread.

@Shjim Thanks but I’ve already tried that.

1 Like

Did you set it in ~/.i3/config" and prepend “exec”.

Edit:

exec "setxkbmap -layout us,de"
exec "setxkbmap -option 'grp:alt_shift_toggle'"

You were absolutely correct.

I installed EndeavorOS + i3wm on a virtual machine, ran the localectl from OP, forced the VM install to boot in tty, ran startx and then xterm. In that terminal the alt/shift binding worked flawlessly.

I don’t know where to go from here but this is progress!

Edit: Forgot to mention that the problem appeared on the clean install on the VM before doing the tty stuff. Switching back to graphical.target the problem has reappeared.

Now we know that i3wm is the problem.

Dont know, and this must answer a EndeavourOS dev, or somebody knows, but is X11 used with i3wm? Or Wayland?

Do you know wich Login Manager is used with i3wm?

And for interest, are the keybindings from i3wm self working? If yes, you could circumvent the whole problem and set in i3wm self a hotkey/what_ever to execute the switching… (not the finest solution, but possible)

Welcome to the forum @tjonmundsson :enos: :enos_flag: :balloon: