Ctrl K

Switch Keyboard Layout with setxkbmap

Manually switch the active keyboard layout in an i3/X11 session with setxkbmap, for example between US English and Turkish Q, with no shortcut or auto-switching.

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

setxkbmap -query   # show the current layout
setxkbmap us       # switch to US English
setxkbmap tr       # switch to Turkish Q

Check the current layout

Query the active layout for the session.

setxkbmap -query
rules:      evdev
model:      pc105
layout:     us

The layout line is the active layout (us or tr here).

Switch layout

Set the layout, then re-query to confirm the change took effect.

# Turkish Q
setxkbmap tr
setxkbmap -query

# back to US English
setxkbmap us
setxkbmap -query

The 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

A minimal Arch install may not ship setxkbmap. Check whether it exists, then install it if needed.

which setxkbmap

# Arch
sudo pacman -S --needed xorg-setxkbmap