Adding keyboard layouts in i3 - trying different guides without effect

I’m trying i3wm with any depth for the first time - have no experience whatsoever in editing the config file, or with scripts. I have managed to learn a decent amount through guides over the past few days, but one thing (well, not quite - there’s a few others) I can’t accomplish is adding keyboard layouts.

I want to have English and Georgian layouts (locales? I’m not sure if layout is the word I should be using), and the guides I found mentioned adding lines like setxkbmap -model pc104 -layout us,ge -variant ,, -option grp:alt_shift_toggle to the config file. Which I did, but it is not working - the hotkey is not switching languages.

Do I need to add language support first, and if so, where from? I don’t know how to search for distro settings from i3 - not sure what the settings tools are called, so that I could search in the dmenu. And is the above command correct for adding languages/layouts/locales to config file for switching?

Some specifics:

I just added

exec --no-startup-id "setxkbmap -model pc104 -layout us,ge -option grp:alt_shift_toggle"

to the config file, saved it, then used Super+Shift+C ro reload the config, and got the “You have an error in your i3 config file” error. When I click “show errors”, this is the output I get:

ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
ERROR: CONFIG: (in file /home/svalbardsleeperdistrict/.i3/config)
ERROR: CONFIG: Line 417:         bindsym Escape mode "default"
ERROR: CONFIG: Line 418: 
ERROR: CONFIG: Line 419: exec --no-startup-id "setxkbmap -layout us,gr,np -option 'grp:lalt_lshift_toggle'"
ERROR: CONFIG:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR: FYI: You are using i3 version 4.20.1 (2021-11-03)
ERROR: i3-nagbar (12860) did not exit normally. This is not an error if the config was reloaded while a nagbar was active.
ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
ERROR: CONFIG: (in file /home/svalbardsleeperdistrict/.i3/config)
ERROR: CONFIG: Line 417:         bindsym Escape mode "default"
ERROR: CONFIG: Line 418: 
ERROR: CONFIG: Line 419: exec --no-startup-id "setxkbmap -model pc104 -layout us,ge -option grp:alt_shift_toggle"
ERROR: CONFIG:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR: FYI: You are using i3 version 4.20.1 (2021-11-03)

I found another guide that proposed adding this to the config:

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

I did this, reloaded, and got the error message:

ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
ERROR: CONFIG: (in file /home/svalbardsleeperdistrict/.i3/config)
ERROR: CONFIG: Line 417:         bindsym Escape mode "default"
ERROR: CONFIG: Line 418: 
ERROR: CONFIG: Line 419: exec --no-startup-id "setxkbmap -layout us,gr,np -option 'grp:lalt_lshift_toggle'"
ERROR: CONFIG:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR: FYI: You are using i3 version 4.20.1 (2021-11-03)
ERROR: i3-nagbar (12860) did not exit normally. This is not an error if the config was reloaded while a nagbar was active.
ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
ERROR: CONFIG: (in file /home/svalbardsleeperdistrict/.i3/config)
ERROR: CONFIG: Line 417:         bindsym Escape mode "default"
ERROR: CONFIG: Line 418: 
ERROR: CONFIG: Line 419: exec --no-startup-id "setxkbmap -model pc104 -layout us,ge -option grp:alt_shift_toggle"
ERROR: CONFIG:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR: FYI: You are using i3 version 4.20.1 (2021-11-03)
ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
ERROR: CONFIG: (in file /home/svalbardsleeperdistrict/.i3/config)
ERROR: CONFIG: Line 417:         bindsym Escape mode "default"
ERROR: CONFIG: Line 418: 
ERROR: CONFIG: Line 419: exec "setxkbmap -layout us,ge"

Finally, if I use this line in the config file instead:

exec --no-startup-id “setxkbmap -layout us,ge -option grp:alt_shift_toggle”

The error I get is this:

ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
ERROR: CONFIG: (in file /home/svalbardsleeperdistrict/.i3/config)
ERROR: CONFIG: Line 417:         bindsym Escape mode "default"
ERROR: CONFIG: Line 418: 
ERROR: CONFIG: Line 419: exec --no-startup-id "setxkbmap -layout us,gr,np -option 'grp:lalt_lshift_toggle'"
ERROR: CONFIG:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR: FYI: You are using i3 version 4.20.1 (2021-11-03)
ERROR: i3-nagbar (12860) did not exit normally. This is not an error if the config was reloaded while a nagbar was active.
ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
ERROR: CONFIG: (in file /home/svalbardsleeperdistrict/.i3/config)
ERROR: CONFIG: Line 417:         bindsym Escape mode "default"
ERROR: CONFIG: Line 418: 
ERROR: CONFIG: Line 419: exec --no-startup-id "setxkbmap -model pc104 -layout us,ru -option grp:alt_shift_toggle"
ERROR: CONFIG:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR: FYI: You are using i3 version 4.20.1 (2021-11-03)
ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
ERROR: CONFIG: (in file /home/svalbardsleeperdistrict/.i3/config)
ERROR: CONFIG: Line 417:         bindsym Escape mode "default"
ERROR: CONFIG: Line 418: 
ERROR: CONFIG: Line 419: exec "setxkbmap -layout us,ge"

Does this say anything informative to those with experience with i3 config/keyboard layouts?

Try this variant:
exec setxkbmap "us,ge" ",winkeys" "grp:alt_shift_toggle,grp_led:scroll"
You may try it first in your terminal without exec . If it gives results,then paste it in your config and reload i3.
By the way, there’s an excellent manual on i3, but I’m sure you know it.

Thank you for the response. I tried that line, but after reloading through Super+Shift+C and Super+Shift+R, Alt+Shift still doesn’t change between layouts. It also gave me this error report:

ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
ERROR: CONFIG: (in file /home/svalbardsleeperdistrict/.i3/config)
ERROR: CONFIG: Line 417:         bindsym Escape mode "default"
ERROR: CONFIG: Line 418:         
ERROR: CONFIG: Line 419:         exec setxkbmap "us,ge" ",winkeys" "grp:alt_shift_toggle,grp_led:scroll"
ERROR: CONFIG:                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR: FYI: You are using i3 version 4.20.1 (2021-11-03)
ERROR: Received ConfigureNotify for unknown window 0x00600000
ERROR: Received ExposeEvent for unknown window 0x00600000
ERROR: Received ConfigureNotify for unknown window 0x00600000
ERROR: Received ConfigureNotify for unknown window 0x00600000
ERROR: Received ExposeEvent for unknown window 0x00600000
ERROR: Received ConfigureNotify for unknown window 0x00600000
ERROR: Received ConfigureNotify for unknown window 0x00600008

I am aware of the i3 guide, but for someone who is completely inexperienced with the scripts used there, it confuses me more than it helps. e.g. for keyboard layouts, it says

When using multiple keyboard layouts (e.g. with setxkbmap -layout us,ru), you can specify in which XKB group (also called “layout”) a keybinding should be active. By default, keybindings are translated in Group1 and are active in all groups. If you want to override keybindings in one of your layouts, specify the corresponding group. For backwards compatibility, the group “Mode_switch” is an alias for Group2.

I am not sure how to use this to build a line that would switch layouts - obviously setxkbmap -layout us,ru is not enough on its own, and I do not know what other elements I need to add and what they do.

Given enough time, I am confident I can learn the principles, but not being able to do something as basic as add keyboard layouts is keeping me stuck without progress.

Update: I solved the problem. The issue was that for some reason, the line before my entries in config was not ending with } , hence the file perceived the lines I was adding as its continuation.

For anyone who may look for this in the future, the terminal command+config lines that worked for me were:

Terminal commands:

setxkbmap -layout us,ge
setxkbmap -option 'grp:alt_shift_toggle'

config file lines:

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

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.