SETXKBMAP(1)
okay so bestie, you're looking at setxkbmap(1) from the General Commands Manual, and it's literally the utility that sets keymaps and layouts via the X Keyboard Extension. no cap, this is the glow-up your keyboard deserves. ๐
โจ NAME โจ
setxkbmap โ set keymaps and layouts via the X Keyboard Extension. periodt.
๐ธ SYNOPSIS ๐ธ
setxkbmap [options] [layout [variant [option ...]]]
๐ฆ DESCRIPTION ๐ฆ
okay so the setxkbmap utility maps the keyboard to use the specified layout in an X(7) session. for a table of available layouts and options, see xkeyboard-config(7). it's giving "keyboard, but make it fashion."
the options are as follows (yes, all of them โ we're not skipping a single one):
-?,-helpโ prints a message describing the valid input tosetxkbmap. (a little help menu, we love that for us.)-compatname โ specifies the name of the compatibility map component used to construct a keyboard layout.-configfile โ specifies the name of an XKB configuration file which describes the keyboard to be used.-devicedeviceid โ specifies the numeric device id of the input device to be updated with the new keyboard layout. if you don't specify it, the core keyboard device of theXorg(1)server gets updated. (that's the default, bestie.)-displaydisplay โ specifies the display to be updated with the new keyboard layout.-geometryname โ specifies the name of the geometry component used to construct a keyboard layout.-Idirectory โ adds a directory to the list of directories to be used to search for the specified layout or rules files. (stack those search paths, bestie.)-keycodesname โ specifies the name of the keycodes component used to construct a keyboard layout.-keymapname โ specifies the name of the keymap description used to construct a keyboard layout.-layoutname โ specifies the name of the layout used to determine the components which make up the keyboard description. the-layoutoption may only be used once. multiple layouts can be specified as a comma-separated list.-modelname โ specifies the name of the keyboard model used to determine the components which make up the keyboard description. only one model may be specified on the command line.-optionname โ specifies the name of an option to determine the components which make up the keyboard description; multiple options may be specified, one per-optionflag. note thatsetxkbmapadds options specified in the command line to the options that were set before (as saved in root window properties). if you want to replace all previously specified options, use the-optionflag with an empty argument first. (this is the messy part, so read it twice, bestie.)-printโ prints component names in a format acceptable by thexkbcomp(1)keymap compiler and exits. the option can be used for tests instead of a verbose option and in cases when one needs to run both thesetxkbmapandxkbcomp(1)utilities in chain (see below).-queryโ prints the current rules, model, layout, variant, and options, then exits.-rulesfile โ specifies the name of the rules file used to resolve the requested layout and model to a set of component names.-symbolsname โ specifies the name of the symbols component used to construct a keyboard layout.-synchโ forces synchronization for X requests.-typesname โ specifies the name of the types component used to construct a keyboard layout.-variantname โ specifies which variant of the keyboard layout should be used to determine the components which make up the keyboard description. the-variantoption may only be used once. multiple variants can be specified as a comma-separated list and will be matched with the layouts specified with-layout.-v[erbose] [level]โ specifies level of verbosity in output messages. valid levels range from0(least verbose) to10(most verbose). default:5. if no level is specified, each-vor-verboseflag raises the level by 1.-versionโ prints the utility's version number and exits.
๐ง IMPLEMENTATION NOTES ๐ง
an XKB keymap is constructed from a number of components which are compiled only as needed by converting the arguments to the names of XKB configuration files in /usr/share/X11/xkb on the X(7) client. those filenames are then passed to the Xorg(1) server, unless printed to stdout(4), with -print. (the way that it compiles only as needed? highkey efficient.)
๐ FILES ๐
/usr/share/X11/xkbโ source for all XKB components.
โญ EXIT STATUS โญ
the setxkbmap utility exits 0 on success, and >0 if an error occurs. periodt.
๐ EXAMPLES ๐
- rebind the Caps Lock key as an additional Left Control:
setxkbmap -option ctrl:nocaps
- set the layout to US, composing the keymap on the client for situations where XKB component files may differ between the
Xserver(1)and client:
setxkbmap us -print | xkbcomp - $DISPLAY
- reset XKB options:
setxkbmap -option
๐ DIAGNOSTICS ๐
Cannot open display "default display"โ the shell environment is not aware of a currently runningX(7)session. startX(7)before using this utility, or set theDISPLAYenvironment variable. (basically, your shell is lost in the sauce.)Running setxkbmap against an Xwayland serverโ this utility will not run in anXwayland(1)session. use the Wayland Compositor's native XKB configuration method instead. (not me trying to run this in Xwayland โ it's not happening, bestie.)
๐ SEE ALSO ๐
go check out xkbcomp(1), X(7), and xkeyboard-config(7) โ iykyk.
๐ HISTORY ๐
setxkbmap first appeared in XFree86 3.2. (a legend was born.)
this iconic page is from Debian, dated March 29, 2025, and yes it's still SETXKBMAP(1) โ bye bestie, mwah ๐โจ
๐ฆ where this page comes from
- alpine 3.24: setxkbmap-doc 1.3.5-r0 ยท MIT
- arch rolling: xorg-setxkbmap 1.3.5-1 ยท HPND
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms