How can I reload my XKB configuration without restarting my computer or logging back in

11,379

Solution 1

Solution. Run this command. Of course, you could change "us" to your desired keyboard layout.

setxkbmap -layout us

Solution 2

It's answered in Unix Stack Exchange:

https://unix.stackexchange.com/questions/290449/how-to-reload-xserver-after-a-change-in-keyboard-layout

Basically, you do this:

sudo udevadm trigger --subsystem-match=input --action=change

It is also mentioned that the following might be sufficient, please comment on what system setup it alone helped:

# For Ubuntu < 16.04
service keyboard-setup restart
# For Ubuntu >= 16.04
systemctl restart keyboard-setup

You might come across other answers suggesting you delete /var/lib/xkb/*.xkm. That would be an outdated suggestion. At least in Ubuntu, this directory wasn't used for this purpose for quite a few years.

Share:
11,379

Related videos on Youtube

Doug Beney
Author by

Doug Beney

Updated on September 18, 2022

Comments

  • Doug Beney
    Doug Beney over 1 year

    I made a cool, little script that will edit my /usr/share/X11/xkb/symbols/pc file automatically. It is useful when I want to switch between a Mac or Windows keyboard.

    The one problem I've encountered is that I have to log out and then log back in after editing the file in order for the edited configuration to take effect.

    I've tried deleting my xkb cache (/var/lib/xkb/*.xkm), but that did work.

    Any help would be greatly appreciated. Cheers.

  • primfaktor
    primfaktor about 5 years
    Does what you say. The key ingredient for me was an additional -variant foo.
  • Name
    Name over 3 years
    This actually reload "us" keyboard, but unfortunately disables other keyboard layouts (in case of multi-keyboard use).
  • WesternGun
    WesternGun about 3 years
    @Name you can set variants and other things as you like, you can also specify 1+ layouts to switch between. You can find more info in man setxkbmap.
  • WesternGun
    WesternGun about 3 years
    Thanks. This reloads my changes in /usr/share/X11/xkb/keycodes/evdev. Good.
  • user149408
    user149408 almost 3 years
    That doesn’t actually “reload” the keyboard layout, at least not the current one. When I tried on 18.04, it didn’t pick up any of the changes made in /usr/share/X11/xkb/symbols; only sudo udevadm trigger --subsystem-match=input --action=change (also mentioned in the answer and a comment to it) did the trick.