You are not logged in.
Hello,
As the title suggests, I am trying to set my fresh install of Arch to cycle through several keyboard layouts with a keybinding. The ArchWiki covers the topic in this page: Xorg/Keyboard configuration.
I am using `localectl` to make the changes permanent, and the command that I have ran is
sudo localectl set-x11-keymap it,no,se,gb,fr "" "" grp:win_space_toggle
After rebooting the layout is correctly set to `it`, and using the key combination Meta+Space once changes to the second layout, `no`, as expected. However it gets stuck there, if I press Meta+Space again nothing changes and I still type with the `no` layout. Rebooting again resets to the first chosen layout.
I have tested a few different combinations of layouts to see if I could isolate the problem, but honestly the results don't make a lot of sense to me.
`it,no,gb,fr` : doesn't switch after changing to `no`
`it,se,gb,fr` : cycles through as it should
`it,se,us,gb,fr` : cycles through, but skips `fr`
`it,fr,se,gb,no` : doesn't switch after changing to `se`
I test which layout is currently active simply by typing one of the keys that are mapped differently in every layout, in a terminal emulator or other text field.
I have verified that the layout abbreviations are correct with the command
localectl list-x11-keymap-layouts
And here is the output of `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: it,no,se,gb,fr
options: grp:win_space_toggle
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+it+no:2+se:3+gb:4+inet(evdev)+group(win_space_toggle)
geometry: pc(pc105)
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+it+no:2+se:3+gb:4+inet(evdev)+group(win_space_toggle)" };
xkb_geometry { include "pc(pc105)" };
};
I am not sure that this affects the keyboard layouts, but I have also uncommented/enabled the following lines in the file `/etc/locale.gen`, before re-generating the locales with `locale-gen`:
en_GB.UTF-8 UTF-8
en_US.UTF-8 UTF-8
fr_FR.UTF-8 UTF-8
it_IT.UTF-8 UTF-8
nb_NO.UTF-8 UTF-8
sv_SE.UTF-8 UTF-8
I appreciate any help that I can get on this issue that I am facing, thank you.
Last edited by itsmeciao (2021-05-02 18:03:25)
Offline
I ended up using a widget built into Qtile and modifying it a little to be able to cycle backwards with a second key combination. See my comment on that here.
I guess I shouldn't mark the post as solved, since I still don't know if there was a more appropriate way to set keyboard layouts in a more "native" way, or if I was using `localectl` wrong, or if I stumbled into some weird bug again. Please let me know if you disagree.
Offline
Do
xdotool key ISO_Next_Group
xdotool key ISO_Prev_Group
move the layout w/o problems?
I suppose some layouts may mess w/ the configured group toggle (and on top of that I'm actually not sure whether a *toggle* will cycle unidirectionally)
Offline
I have just reused the first ´localectl´ command I tried to set the layouts `it,no,se,gb,fr`, and it seems like `xdotool` won't help. The first time it switches from `it` to `no`, but from there neither of the commands you suggested have any effect, just like it happens with the key combination.
Edit to point out that before switching to Arch and finding this problem, I used to run Manjaro with KDE, and there I had an issue with the layout switching that maybe resembled this one. I used the layouts configuration GUI included in KDE, and I had configured the same layouts that I need now, in the same order: it, no, se, gb, fr. When switching with the shortcut it would work but always skip the last layout, `fr`; if I then went and manually selected the last layout in the drop-down menu, the shortcut would still work, but now it would always skip the second-to-last layout, `gb`. I have no idea if the KDE layouts configuration software uses `localectl` or simply calls `setxkbmap` every time like the Qtile widget does. Before now I thought that it was a weird but intentional design, but now this could be proof that it is in fact a bug with `localectl` or another tool.
Last edited by itsmeciao (2021-05-02 14:28:50)
Offline
Does the actual "grp:*toggle" have an impact (eg. if you use "grp:ctrl_alt_toggle")?
Offline
Okay, here is what I have tried now:
I reused the same `localectl` command with a different `grp:*toggle` and rebooted:
sudo localectl set-x11-keymap it,no,se,gb,fr "" "" grp:ctrl_alt_toggle
The `grp:*toggle` does in fact seem to have an effect, and this time I observed the same behaviour that I experienced in Manjaro KDE (see edit on post #4): I was able to use the key combination Ctrl+Alt to cycle through the layouts it, no, se, gb; that is, skipping the last layout in the list `fr`. I tried to manually switch to `fr` with
setxkbmap fr
and the cycling stopped working, both with the key combination and with `xdotool`. I can still manually switch with `setxkbmap`.
Offline
I can still manually switch with `setxkbmap`.
That's not surprising and does something different that merely cycling through a list of layouts - which is why
and the cycling stopped working
doesn't surprise either - you nuked all layouts but one (fr)
Did you really move "it, no, se, gb, it, no, se, gb, it, no, se, gb, …" ie truely cycling but skipping the last layout?
In that case it might just be a memory limitation and a "fr, it, no, se, gb" would probably skip gb - I'm not what your usecase is, but the entire layout selection was probaly not meant for this many layouts (but eg. to quickly switch between qwerty and azerty or so)
Offline
That's not surprising and does something different that merely cycling through a list of layouts
Yeah true, what I wanted to point out but totally failed to is that even after switching back to the other layouts like the first, the cycle would still be broken. But as you said already that's because upon running `setxkbmap` I have basically cleared the previous layout list.
Did you really move "it, no, se, gb, it, no, se, gb, it, no, se, gb, …" ie truely cycling but skipping the last layout?
Yep, and I just found this piece of documentation:
You can use multi-layouts xkb configuration. What does it mean? Basically it allows to load up to four different keyboard layouts at a time.
It's not a bug, but peculiar, intentional design (or a bug masked as a feature for what I know, I'm not prepared to dig through that haha). So yeah I was not using it in the intended way.
Thanks for the assistance
Offline