Score:1

Reload current keyboard layout after making changes

us flag

I am developing bug fixes to keyboard layouts.

For now, I am not adding any new layouts; I am just making changes to existing ones. I do this by directly modifying the layout files in /usr/share/X11/xkb/symbols.

After making a change, I would like to test if it behaves as expected. Usually this affects the keyboard layout which is already active on my machine. I am in an X11 session, not on a tty console.

How can I tell Ubuntu to reload the current keyboard layout from symbols files?

us flag
@UnKNOWn I am on MATE. Alt+F2 gives me the *Run application* dialog. `systemctl restart keyboard-setup` does not seem to have any effect.
br flag
Ok. @N0rbert Will help you soon on this.
Gunnar Hjalmarsson avatar
uz flag
AFAIK you don't need to do anything besides switching to the layout(s) you changed.
us flag
@GunnarHjalmarsson maybe, but what if I’m editing the currently active layout (which is my primary use case)? Does the OS cut some corners à la “switching to an already active layout is a no-op”? In that case I may have to jump through some extra hoops (switch to a different layout and back again). Anyways, I have found an answer which works for that particular use case (on 18.04), see below.
Gunnar Hjalmarsson avatar
uz flag
@user149408: Right, switching to some other layout and back again may be necessary if you edit the active layout. Good to know that there is another way too.
Score:1
us flag

From https://unix.stackexchange.com/a/385725/91283 (originally from https://wiki.debian.org/Keyboard):

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

Worked for me.

Score:0
ph flag

you can use setxkbmap for that. Here an example to switch (or re-read) the german de layout with the variant deadacute.

setxkbmap de -variant deadacute -v

Another useful flags are -option (to use with options such as grp:alt_shift_toggle or kpdl:comma).

The -v flag, for verbose, can be very useful when the layout does not compile for some reason. If it does not compile you can set a higher verbose level (integer from 0 to 10, default: 5) to better trace the error.

For more details, man setxkbmap.

us flag
As I understand it, that switches the layout. Fine if I’m, say, on Krakhozian (standard), and want to test out my brand new Krakhozian (programmer) layout. However, if I am making changes to the Krakhozian (standard) layout while it is active, not sure if the OS cuts some corners à la “switching to a layout that is already active is a no-op”, though there is a way to just reload whatever is active; see my answer.
avila avatar
ph flag
strange, because it works for me... whenever I am editing a layout I try it via setxkbmap. In any case, I'm glad you found a solution that works for you :)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.