Skip to content

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.

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

Query the active layout for the session.

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

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

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

Terminal window
# 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.

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

Terminal window
which setxkbmap
# Arch
sudo pacman -S --needed xorg-setxkbmap