I am using 'i3` window manager on Fedora 25. I've already uninstalled GNOME Desktop. I want to change keyboard layout and set it to languages other than English, and desirably also to set it as Alt+Shift shortcut for easy access.
8 Answers
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
- 976
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
- 211
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"
- 101
The desired shortcut set by XKB option grp:alt_shift_toggle
But using setxkbmap -option in ~/.i3/config for configuring keyboard layouts is not the best approach.
- Bluetooth keyboards can go to sleep to save battery then reconnect. In that case layout configuration will be reset to default.
- There is no way to configure keyboards separate. For example, my Bluetooth keyboard has no Right Alt so I am using Caps Lock on it.
If this is your case consider using /etc/X11/xorg.conf.d/00-keyboard.conf (man xorg.conf DESCRIPTION for all available paths):
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "us,ru"
Option "XkbOptions" "grp:toggle"
EndSection
Section "InputClass"
Identifier "Bluetooth Keyboard"
MatchIsKeyboard "on"
MatchProduct "Bluetooth 3.0 Keyboard"
Option "XkbLayout" "us,ru"
Option "XkbOptions" "grp:alt_shift_toggle,grp_led:caps"
EndSection
See man xkeyboard-config
- LAYOUTS for language codes in
XkbLayout - OPTIONS for switching to another layout hotkeys (all
grp:*)
Or: https://unix.stackexchange.com/a/45499/384576
See xinput list for MatchProduct
- 21
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
"exec setxkbmap" didn't work for me. Through frustrated keyboard smashing, I accidentally pulled up the display settings (Super+D since I installed from Regolith-desktop), and from there I could open up "Region & Language" to set the keyboard layout. I guess i3 "Ubuntu" keyboard layout settings are store separate from "Kubuntu" keyboard layout settings.
- 123
my setup:
gnome manjaro + i3 default
1 step - cd ~/.config/i3/ and edit config (example vi or nvim confif)
2 step past this line exec_always "setxkbmap -model pc104 -layout us,ru,ua -variant ,, -option grp:alt_shift_toggle" if you need to change language
- 11
for some reason, the other solutions didn't work for me.
I use this bash script instead
LAYOUT=$(setxkbmap -query | grep layout | awk '{print $2}')
case $LAYOUT in
us)
setxkbmap br
;;
br)
setxkbmap us
;;
esac
Just change the case statement for the languages you want to use.
and then in your i3config add
bindsym <YOUR_KEYBIND> exec <PATH_TO_SCRIPT>
- 1