The Computer Oracle

How to change keyboard layout in i3?

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Mysterious Puzzle

--

Chapters
00:00 Question
00:32 Accepted answer (Score 83)
01:01 Answer 2 (Score 9)
01:28 Answer 3 (Score 9)
01:50 Answer 4 (Score 1)
03:35 Thank you

--

Full question
https://superuser.com/questions/1147320/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #keyboardlayout #i3windowmanager

#avk47



ACCEPTED ANSWER

Score 86


You can use setxkbmap:

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

Just change the keyboard layouts us,de to what ever you prefer. If you want i3 to run these commands on startup, just add them to your config file "~/.i3/config" and prepend "exec".

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

Checkout http://docs.slackware.com/howtos:window_managers:keyboard_layout_in_i3




ANSWER 2

Score 11


For me only the following worked in Manjaro + i3:

exec_always "setxkbmap -model pc104 -layout us,ru,ua -variant ,, -option grp:alt_shift_toggle"

I specified this in ~/.config/i3/config file




ANSWER 3

Score 10


It indeed seems that everything must be written inside a single command in the i3 config file in order for setxkbmap to work as desired, at least on Arch linux.

Example: English + Czech qwerty keyboard, ALT+SHIFT toggle:

exec "setxkbmap -option 'grp:alt_shift_toggle' -layout us,cz -variant ,qwerty"



ANSWER 4

Score 1


insert into your .config/i3/config

# switch keymap

bindsym $mod+Ctrl+Shift+F11 exec setxkbmap -layout ch -variant fr
bindsym $mod+Ctrl+Shift+F12 exec setxkbmap -layout ru -variant phonetic