Switch Keyboard Layout with setxkbmap
Switch the keyboard layout for the current X session with setxkbmap, using US English and Turkish Q as the example pair. The switch is manual and explicit by choice: no i3 shortcut, no helper script, no automatic switching. A shortcut is easy to trigger by accident while coding with symbols and punctuation, so a plain command is preferred. The change is immediate and affects all running apps (terminal, Firefox, VS Code, and so on), but resets after logout or reboot.
Quick reference
Section titled “Quick reference”setxkbmap -query # show the current layoutsetxkbmap us # switch to US Englishsetxkbmap tr # switch to Turkish QCheck the current layout
Section titled “Check the current layout”Query the active layout for the session.
setxkbmap -queryrules: evdevmodel: pc105layout: usThe layout line is the active layout (us or tr here).
Switch layout
Section titled “Switch layout”Set the layout, then re-query to confirm the change took effect.
# Turkish Qsetxkbmap trsetxkbmap -query
# back to US Englishsetxkbmap ussetxkbmap -queryThe switch is immediate, applies to every app in the session, and needs no reboot. It resets on logout, reboot, or a fresh startx, so re-run the command if the layout reverts.
Install setxkbmap if missing
Section titled “Install setxkbmap if missing”A minimal Arch install may not ship setxkbmap. Check whether it exists, then install it if needed.
which setxkbmap
# Archsudo pacman -S --needed xorg-setxkbmap