LinuxCommandLibrary

setxkbmap

TLDR

Set the keyboard layout to French AZERTY

$ setxkbmap fr
copy
Set multiple layouts with switching option
$ setxkbmap -layout us,de -variant ,qwerty -option 'grp:alt_caps_toggle'
copy
Query current keyboard settings
$ setxkbmap -query
copy
Set keyboard model
$ setxkbmap -model pc105 -layout us
copy
Print keymap components without applying
$ setxkbmap -layout us -print
copy
Set layout for a specific input device
$ setxkbmap -device [device_id] -layout [layout]
copy

SYNOPSIS

setxkbmap [args] [layout [variant [option...]]]

DESCRIPTION

setxkbmap configures keyboard layouts for the X Window System using the X Keyboard Extension (XKB). It builds keymaps from components stored in /usr/share/X11/xkb and applies them to the current X session.
The command supports multiple keyboard layouts that can be switched using configurable key combinations (options). Common switching options include grp:alt_shift_toggle, grp:caps_toggle, and grp:win_space_toggle.

PARAMETERS

-layout name

Specifies layout name (comma-separated for multiple layouts)
-variant name
Specifies layout variant (comma-separated, matching layout order)
-model name
Specifies keyboard model (e.g., pc104, pc105, thinkpad)
-option name
Specifies XKB option (can be used multiple times)
-device device
Numeric device ID to update (default: core keyboard)
-display display
X display to update
-config file
XKB configuration file describing keyboard
-rules file
Rules file for resolving layout to components
-query
Display current rules, model, layout, variant, and options
-print
Output component names in xkbcomp format, then exit
-I directory
Add directory to search path for layout files
-v, -verbose [level]
Set verbosity level (0-10, default 5)
-help
Display usage information
-version
Print program version

CAVEATS

Changes are session-only and do not persist across X restarts. For permanent changes, configure through desktop environment settings, /etc/X11/xorg.conf.d/, or systemd's localectl. Does not work in Wayland sessions; use compositor-specific tools instead. Layout names vary by distribution.

HISTORY

setxkbmap is part of the X Keyboard Extension (XKB), which was developed in the mid-1990s to replace the older core X keyboard protocol. XKB was integrated into XFree86 and later X.Org, becoming the standard keyboard configuration mechanism for X11. The tool is maintained as part of the xorg-x11-xkb-utils package.

SEE ALSO

Copied to clipboard