Xorg/Keyboard configuration - ArchWiki (2024)

Related articles

  • X keyboard extension
  • Linux console/Keyboard configuration
  • Extra keyboard keys
  • Xorg
  • Keyboard shortcuts

This article describes the basics of Xorg keyboard configuration. For advanced topics such as keyboard layout modification or additional key mappings, see X keyboard extension or Extra keyboard keys respectively.

The Xorg server uses the X keyboard extension (XKB) to define keyboard layouts. Optionally, xmodmap can be used to access the internal keymap table directly, although this is not recommended for complex tasks. Also systemd's localectl can be used to define the keyboard layout for both the Xorg server and the virtual console.

Note: XKB options can be overridden by the tools provided by some desktop environments such as GNOME and Plasma.

Viewing keyboard settings

You can use the following command to see the actual XKB settings:

$ setxkbmap -print -verbose 10
Setting verbose level to 10locale is CApplied rules from evdev:model: evdevlayout: usoptions: terminate:ctrl_alt_bkspTrying to build keymap using the following components:keycodes: evdev+aliases(qwerty)types: completecompat: completesymbols: pc+us+inet(evdev)+terminate(ctrl_alt_bksp)geometry: pc(pc104)xkb_keymap { xkb_keycodes { include "evdev+aliases(qwerty)" }; xkb_types { include "complete" }; xkb_compat { include "complete" }; xkb_symbols { include "pc+us+inet(evdev)+terminate(ctrl_alt_bksp)" }; xkb_geometry { include "pc(pc104)" };};

Third party utilities

There are some "unofficial" utilities which allow to print specific information about the currently used keyboard layout.

  • xkb-switch-gitAUR:
$ xkb-switch
us
  • xkblayout-state-gitAUR:
$ xkblayout-state print "%s"
de

Setting keyboard layout

Keyboard layout in Xorg can be set in multiple ways. Here is an explanation of used options:

  • XkbModel selects the keyboard model. This has an influence only for some extra keys your keyboard might have. The safe fallback are pc104 (ANSI) or pc105 (ISO). But for instance laptops usually have some extra keys, and sometimes you can make them work by simply setting a proper model.
  • XkbLayout selects the keyboard layout. Multiple layouts may be specified in a comma-separated list, e.g. if you want to quickly switch between layouts.
  • XkbVariant selects a specific layout variant available for the XkbLayout. For instance, the default sk (Slovak) variant is qwertz, but you can manually specify qwerty, etc.
  • XkbOptions contains some extra options (comma-separated). Used for specifying layout switching, notification LED, compose mode etc. See the #Frequently used XKB options section for examples.

Note: You must specify as many variants as the number of specified layouts. If you want the default variant, specify an empty string as the variant (the comma must stay). For example, to have the default us layout as primary and the dvorak variant of us layout as secondary, specify us,us as XkbLayout and ,dvorak as XkbVariant.

The layout name is usually a 2-letter country code. To see a full list of keyboard models, layouts, variants and options, along with a short description, open /usr/share/X11/xkb/rules/base.lst. Alternatively, you may use one of the following commands to see a list without a description:

  • localectl list-x11-keymap-models
  • localectl list-x11-keymap-layouts
  • localectl list-x11-keymap-variants [layout]
  • localectl list-x11-keymap-options

Examples in the following subsections will have the same effect, they will set pc104 model, cz as primary layout, us as secondary layout, dvorak variant for us layout and the Win+Space combination for switching between layouts. See xkeyboard-config(7) for more detailed information.

Note: Fcitx/IBus users may find these methods not working, or just work for a while, since they will try to control keyboard layout. Fcitx users need to set the first input method to be Keyboard - layout. See Fcitx#Input methods configuration. IBus users need to enable "Use system keyboard layout" option in Preference -> Advanced if using X configuration files, or manually specify the layout if using setxkbmap.

Using setxkbmap

Xorg/Keyboard configuration - ArchWiki (1)This article or section needs expansion.

Reason: Udev also comes into play (for example when plugging in a keyboard), undoing changes by setxkbmap (Discuss in Talk:Xorg/Keyboard configuration#Persisting layout when USB keyboard connected)

setxkbmap sets the keyboard layout for the current X session only, but can be made persistent in xinitrc or xprofile. This overrides system-wide configuration specified following #Using X configuration files. However, persistence does not apply to keyboards such as external keyboards, unless their device id was specified when setxkbmap was run. Or that they are the core keyboard device of the X server.

The usage is as follows (see setxkbmap(1)):

$ setxkbmap [-model xkb_model] [-layout xkb_layout] [-variant xkb_variant] [-option xkb_options]

Note: setxkbmap adds 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 -option flag with an empty argument first.

To change just the layout (-layout is the default flag):

$ setxkbmap xkb_layout

For multiple customizations:

$ setxkbmap -model pc104 -layout cz,us -variant ,dvorak -option grp:win_space_toggle

Using X configuration files

Note: xorg.conf is parsed by the X server at start-up. To apply changes, restart X.

The syntax of X configuration files is explained in Xorg#Configuration. This method creates system-wide configuration which is persistent across reboots.

Here is an example:

/etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputClass" Identifier "system-keyboard" MatchIsKeyboard "on" Option "XkbLayout" "cz,us" Option "XkbModel" "pc104" Option "XkbVariant" ",dvorak" Option "XkbOptions" "grp:win_space_toggle"EndSection

Using localectl

For convenience, the tool localectl may be used instead of manually editing X configuration files. It will save the configuration in /etc/X11/xorg.conf.d/00-keyboard.conf, this file should not be manually edited, because localectl will overwrite the changes on next start.

The usage is as follows:

# localectl [--no-convert] set-x11-keymap layout [model [variant [options]]]

To set a model, variant or options, all preceding fields need to be specified, but the preceding fields can be skipped by passing an empty string with "". Unless the --no-convert option is passed, the specified keymap is also converted to the closest matching console keymap and applied to the console configuration in vconsole.conf. See localectl(1) for more information.

To create a /etc/X11/xorg.conf.d/00-keyboard.conf like the above:

# localectl --no-convert set-x11-keymap cz,us pc104 ,dvorak grp:win_space_toggle

Tip: localectl additionally writes the keyboard configuration to /etc/vconsole.conf using variables XKBLAYOUT, XKBMODEL, XKBVARIANT and XKBOPTIONS, [1] but the Xorg server does not read them from that file.

Frequently used XKB options

Switching between keyboard layouts

To be able to easily switch keyboard layouts, first specify multiple layouts between which you want to switch (the first one is the default). Then specify a key (or key combination), which will be used for switching. For example, to switch between a US and a Swedish layout using the CapsLock key, use us,se as an argument of XkbLayout and grp:caps_toggle as an argument of XkbOptions. The number of XkbLayouts should match that of the XkbVariants — if you want to switch solely between different variants, then duplicate the layout accordingly (e.g. de,de).

The list of available layouts (and variants) can be found in xkeyboard-config(7) § LAYOUTS. The key combinations available for layout switching are listed in xkeyboard-config(7) § Switching to another layout.

Note that the grp:alts_toggle option is unreliable and unlikely to be fixed; prefer other combinations.

Switch languages using Alt Shift

To set Alt+Shift as a layout shortcut, use grp:alt_shift_toggle in XkbOptions.

However, there is a known issue with XKB that causes other shortcuts of the type Alt+Shift+any_key to break. Moreover, XKB may set the right Alt to be AltGr by default in some keyboard layouts, making RAlt+RShift not working for layout switching.

As a workaround, sxhkd may be used to switch layouts by adding the following to sxhkdrc:

Shift_L + Alt_L setxkbmap -query | grep -q 'fr' && setxkbmap us || setxkbmap fr,usShift_R + Alt_R setxkbmap -query | grep -q 'fr' && setxkbmap us || setxkbmap fr,us

Note that for some reason, Alt must be pressed before Shift to be detected by sxhkd.

Terminating Xorg with Ctrl+Alt+Backspace

By default, the key combination Ctrl+Alt+Backspace is disabled. You can enable it by passing terminate:ctrl_alt_bksp to XkbOptions. This can also be done by binding a key to Terminate_Server in xmodmap (which undoes any existing XkbOptions setting). In order for either method to work, one also needs to have DontZap set to "off" in ServerFlags: since 2004 [2] this is the default.

Swapping Caps Lock with Left Control

To swap Caps Lock with Left Control key, add ctrl:swapcaps to XkbOptions. Run the following command to see similar options along with their descriptions:

$ grep -E "(ctrl|caps):" /usr/share/X11/xkb/rules/base.lst

Enabling mouse keys

Mouse keys, not to be confused with the keys of the mouse, is disabled by default and has to be manually enabled by passing keypad:pointerkeys to XkbOptions. This will make the Shift+NumLock shortcut toggle mouse keys.

See also X keyboard extension#Mouse control for advanced configuration.

Configuring AltGr

The AltGr (Alternate Graphic) key can be used to access additional characters and symbols on a keyboard. It functions as a modifier key similar to Shift but provides access to a third level of key mappings. Note that mapping levels work as follows:

  • 1st Level: Default layer of keys (no modifier).
  • 2nd Level: Accessed by pressing the Shift key, providing secondary characters (e.g. capitalization) or symbols (e.g. @ symbol).
  • 3rd Level: Accessed by pressing the AltGr key, allowing access to additional characters or symbols not available on the 1st and 2nd levels.

2nd level characters are usually printed on keyboard keys and are easy to find. On the other hand, to check the characters on additional levels, you can use xmodmap -pk or look up your keyboard mapping on /usr/share/X11/xkb/symbols.

Configuring compose key

Though typically not on traditional keyboards, a Compose key can be configured to an existent key.

The Compose key begins a keypress sequence that involves (usually two) additional keypresses. Usage is typically either for entering characters in a language that the keyboard was not designed for, or for other less-used characters that are not covered with the AltGr modifier. For example, pressing Compose ' e produces é, or Compose - - - will produce an "em dash": .

Though a few more eccentric keyboards feature a Compose key, its availability is usually through substituting an already existing key to it. For example, to make the Menu key a Compose key use the Desktop environment configuration, or pass compose:menu to XkbOptions (or setxkbmap: setxkbmap -option compose:menu). Allowed key substitutions are defined in /usr/share/X11/xkb/rules/base.lst:

$ grep "compose:" /usr/share/X11/xkb/rules/base.lst

If the desired mapping is not found in that file, an alternative is to use xmodmap to map the desired key to the Multi_key keysym, which acts as a compose key by default (note that xmodmap settings are reset by setxkbmap).

Key combinations

The default combinations for the compose keys depend on the locale configured for the session and are stored in /usr/share/X11/locale/used_locale/Compose, where used_locale is for example en_US.UTF-8.

You can define your own compose key combinations by copying the default file to ~/.XCompose and editing it. Alternatively, create an empty ~/.XCompose and include the default one using include "%L", for example:

~/.XCompose
include "%L"<Multi_key> <g> <a>: "α"<Multi_key> <g> <b>: "β"<Multi_key> <g> <g>: "γ"

The compose key (denoted as <Multi_key> in the ~/.XCompose file) works with any of the thousands of valid Unicode characters, including those outside the Basic Multilingual Plane. Take a look at the Compose(5) man page, it explains the format of the XCompose files.

However, GTK does not use XIM by default and therefore does not follow ~/.XCompose keys. This can be fixed by forcing GTK to use XIM by configure the graphical environment variables GTK_IM_MODULE=xim and/or XMODIFIERS="@im=none".

Tip: XIM is very old, you might have better luck with other input methods such as IBus and Fcitx5; see Input method for details.

Note: XIM will prevent insertion of Unicode characters with the Ctrl+Shift+u combination.

Currency sign on other key

Most European keyboards have a Euro sign (€) printed on on the 5 key. For example, to access it with Alt+5, use the lv3:ralt_switch and eurosign:5 options.

The Rupee sign (₹) can be used the same way with rupeesign:4.

Switching state immediately when Caps Lock is pressed

Those who prefer typing capital letters with the Caps Lock key may experience a short delay when Caps Lock state is switched, resulting in two or more capital letters (e.g. THe, ARch LInux). This occurs because Caps Lock is enabled immediately once the Caps Lock key is pressed, but is only disabled upon release of the second key-press. This behaviour stems from typewriters where a Caps Lock function was achieved by physically locking the shifted typebars in place, and the release of a shift key-press was the action that caused the release of the lock.

Some more popular operating systems have removed this behaviour, either voluntarily (as it can be confusing to some) or by mistake, however this is a question of preference. Bug reports have been filed on the Xserver bug tracker, as there is currently no easy way to switch to the behaviour reflected by those other operating systems. For anyone who would like to follow up the issue, bug reports and latest working progress can be found at [3] and [4].

Workaround

First, export your keyboard configurations to a file:

$ xkbcomp -xkb $DISPLAY xkbmap

In the file xkbmap, locate the Caps Lock section which begins with key <CAPS>:

 key <CAPS> { [ Caps_Lock ] };

and replace whole section with the following code:

key <CAPS> { repeat=no, type[group1]="ALPHABETIC", symbols[group1]=[ Caps_Lock, Caps_Lock], actions[group1]=[ LockMods(modifiers=Lock), Private(type=3,data[0]=1,data[1]=3,data[2]=3)]};

Save and reload keyboard configurations:

$ xkbcomp -w 0 xkbmap $DISPLAY

Consider making it a service launching after X starts, since reloaded configurations do not survive a system reboot.

One-click key functions

To assign an additional one-click function to a modifier key, you can use xcape. For example it is possible to have CapsLock work as Escape when pressed alone, and as Control when used with another key. First set the Control swapping using setxkbmap as mentioned earlier, and xcape to set the Escape association:

 $ xcape -e 'Caps_Lock=Escape'

You can set multiple associations separated with a semicolon, e.g.: Caps_Lock=Escape;Shift_L=Escape.

If you hold a key for longer than the timeout value (default 500 ms), xcape will not generate a key event.

Adjusting typematic delay and rate

The typematic delay indicates the amount of time (typically in milliseconds) a key needs to be pressed and held in order for the repeating process to begin. After the repeating process has been triggered, the character will be repeated with a certain frequency (usually given in Hz) specified by the typematic rate. Note that these settings are configured separately for Xorg and for the virtual console.

Using xset

The tool xset, provided by xorg-xset, can be used to set the typematic delay and rate for an active X server, though certain actions during runtime may cause the X server to reset these changes and revert instead to its seat defaults.

Usage:

$ xset r rate delay [rate]

For example to set a typematic delay to 200ms and a typematic rate to 30Hz, use the following command:

$ xset r rate 200 30

Issuing the command without specifying the delay and rate will reset the typematic values to their respective defaults; a delay of 660ms and a rate of 25Hz:

$ xset r rate

Using xautocfg

xautocfgAUR can apply repeat rate settings for newly connected devices automatically. It watches for X11 events and applies repeat rate configuration to newly connected keyboards.

Adjust the configuration:

~/.config/xautocfg.cfg
[keyboard]# repeat delay in msdelay = 200# repeat rate in Hzrate = 30

If graphical-session.target is started by your window manager or desktop environment, enable the systemd/User xautocfg.service. Alternatively, launch xautocfg manually.

Using AutoRepeat configuration option

To persist the configuration system-wide, change the seat defaults with an Xorg configuration file as described in #Using X configuration files, and add a AutoRepeat section entry: [5]

The parameters for AutoRepeat are delay and interval in milliseconds. If you like 25 Hz rate of xset, the corresponding interval 1000 / 25 = 40 milliseconds.

/etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputClass" ... Option "AutoRepeat" "200 40" ...EndSection

Using XServer startup options

Another method of persisting the configuration is to pass the desired settings to the X server on its startup using the following options:

  • -ardelay milliseconds - sets the autorepeat delay (length of time in milliseconds that a key must be depressed before autorepeat starts).
  • -arinterval milliseconds - sets the autorepeat interval (length of time in milliseconds that should elapse between autorepeat-generated keystrokes).

See Xserver(1) for a full list of X server options and refer to your display manager for information about how to pass these options.

See also

Xorg/Keyboard configuration - ArchWiki (2024)

FAQs

How to enable Xorg Arch? ›

Starting X
  1. First make a copy of the default xinitrc in your home directory: ...
  2. Open the just-copied ~/. ...
  3. Install a terminal emulator. ...
  4. After creating an xinitrc file, you can start the X Window System by running startx from the Linux console.

How to change arch linux keyboard language? ›

I think there's multiple options:
  1. u can use the command setxkbmap -layout uk to change the layout to UK English for the current session. You can also add this command to your . ...
  2. u can use the localectl tool to set the console and Xorg keyboard layout. ...
  3. u can also edit the /etc/vconsole.
Oct 12, 2023

How to set an X11 layout? ›

Display multiple keyboard layouts without using localectl
  1. Find the codes of the desired language layouts in the /usr/share/X11/xkb/rules/base. ...
  2. Add the layout codes to /usr/share/X11/xorg.conf.d/10-evdev.conf in the following way: ...
  3. Log out to find that the defined layouts are available at the top bar on the login screen.

What are the different keyboard layouts in Linux? ›

Some examples of standard keyboard layouts are QWERTY, AZERTY, QWERTZ, and Dvorak. The keyboard layout affects how the keys are arranged and what characters they produce when pressed.

Is Xorg.conf needed? ›

Newer versions of Xorg are auto-configuring, so manual configuration should not be needed. If Xorg is unable to detect any monitor or to avoid auto-configuring, a configuration file can be used.

Is Wayland better than Xorg? ›

Client-side rendering: The primary benefit of using Wayland is client-side rendering. This approach is more modern and streamlined than Xorg. Wayland removes the middleman from the client/server method, which allows an application to communicate directly with the compositor.

How to configure keyboard in Linux? ›

If you want additional keyboard layouts, follow these steps:
  1. Open the Menu and click on System Settings:
  2. Click on Keyboards:
  3. Click on the Layouts tab and then on the plus sign in the lower left corner:
  4. Find and select the keyboard layout you want, and click Add:

How do I change my default keyboard language? ›

From the Start menu, search for Control Panel, and open Control Panel. Under Clock, Language, and Region, click Change input methods. Note: If you don't see Clock, Language, and Region, click Category in the View by menu at the top of the page. Optional: Click Add a language to add a new language.

How do I enable X11 on Linux? ›

Enable X11 Forwarding
  1. Open the SSH daemon configuration file. $ sudo vi /etc/ssh/sshd_config.
  2. Locate and uncomment or change line X11Forwarding to be X11Forwarding yes . ...
  3. Restart SSH daemon. ...
  4. Install the graphical application xclock for testing.

Does Wayland use XKB? ›

Keymaps are an essential detail involved in keyboard input, and XKB is the recommended way of handling them on Wayland.

How to know keyboard model in Linux? ›

Naturally, we can use the setxkbmap command to view the name of the current keyboard layout on the terminal. Then, we can pass this name to the gkbd-keyboard-display command to view the graphical representation of the configured keyboard layout.

What is the most useful keyboard layout? ›

A lot of tests and demonstrations have shown that DVORAK is a lot better than QWERTY. Estimates are that you can be more than 60 per cent faster typing on a DVORAK keyboard. The layout that takes the crown however is called Colemak. Colemak is relatively newer, and it's easier to adapt as well.

What are the 4 keyboard layouts? ›

Latin-script keyboard layouts

These layouts are usually named after the first six letters on the first row: AZERTY, QWERTY, QWERTZ, QZERTY and national variants thereof.

What are the 5 keyboard layouts? ›

What are the most common types of keyboard layouts? Keyboard layouts vary globally across regions and languages, with popular types like QWERTY, AZERTY, QWERTZ, and Dvorak. The QWERTY layout, named after its top row letters, is the standard worldwide.

How do I enable Flatpak in Arch Linux? ›

Arch Quick Setup
  1. Install Flatpak. To install Flatpak on Arch, simply run: $ sudo pacman -S flatpak.
  2. Restart. To complete setup, restart your system. Now all you have to do is install some apps!

How do I activate Xorg in Ubuntu? ›

Ubuntu 21: Login screen cog
  1. Restart computer.
  2. Select the small cog on the bottom right corner at the login screen.
  3. Choose 'Ubuntu on Xorg' and login.

How do I enable Zswap on Arch Linux? ›

Toggling zswap

All officially supported kernels have zswap enabled by default. This can be verified with zgrep CONFIG_ZSWAP_DEFAULT_ON /proc/config. gz . To disable zswap permanently, add zswap.

How do I enable print in Arch Linux? ›

CUPS Installation
  1. Install packages. # pacman -Syy cups cups-pdf. Remove "cups-pdf" if a virtual PDF printer is not desired.
  2. Enable service. Choose only one of the following commands to enable. # systemctl enable cups.service. ...
  3. Start service. Only do this step if you chosen in previous step to enable cups. service .

Top Articles
Best German Translator Apps for English Speakers - My Germany Vacation
3 Ways to Teach Articles - wikiHow
Sdn Md 2023-2024
Custom Screensaver On The Non-touch Kindle 4
Lakers Game Summary
Is Sam's Club Plus worth it? What to know about the premium warehouse membership before you sign up
Cintas Pay Bill
Zabor Funeral Home Inc
Valley Fair Tickets Costco
Affidea ExpressCare - Affidea Ireland
Hotels Near 500 W Sunshine St Springfield Mo 65807
Erin Kate Dolan Twitter
Mycarolinas Login
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
Costco Gas Foster City
Flower Mound Clavicle Trauma
Hair Love Salon Bradley Beach
Https://Store-Kronos.kohls.com/Wfc
Costco Gas Foster City
Enterprise Car Sales Jacksonville Used Cars
Youravon Comcom
Dr Adj Redist Cadv Prin Amex Charge
Best Uf Sororities
Average Salary in Philippines in 2024 - Timeular
Www Craigslist Milwaukee Wi
Ibukunore
Toothio Login
Understanding Gestalt Principles: Definition and Examples
Craig Woolard Net Worth
Finding Safety Data Sheets
Remnants of Filth: Yuwu (Novel) Vol. 4
Visit the UK as a Standard Visitor
San Jac Email Log In
Calvin Coolidge: Life in Brief | Miller Center
Bridgestone Tire Dealer Near Me
Halsted Bus Tracker
La Qua Brothers Funeral Home
Jt Closeout World Rushville Indiana
Manuel Pihakis Obituary
Samsung 9C8
Aliciabibs
Trap Candy Strain Leafly
The Wait Odotus 2021 Watch Online Free
3 Zodiac Signs Whose Wishes Come True After The Pisces Moon On September 16
Scythe Banned Combos
Funkin' on the Heights
Contico Tuff Box Replacement Locks
FactoryEye | Enabling data-driven smart manufacturing
Phunextra
Fahrpläne, Preise und Anbieter von Bookaway
Jesus Calling Oct 6
Volstate Portal
Latest Posts
Article information

Author: Domingo Moore

Last Updated:

Views: 6055

Rating: 4.2 / 5 (73 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Domingo Moore

Birthday: 1997-05-20

Address: 6485 Kohler Route, Antonioton, VT 77375-0299

Phone: +3213869077934

Job: Sales Analyst

Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.