You are not logged in.

#1 2019-07-31 16:45:10

AstroSnail
Member
Registered: 2019-07-31
Posts: 2

[SOLVED] Is there a way to include a custom XKB configuration path?

For many reasons of my own, I've decided to write my own XKB configs, which I have stored in /etc/X11/xkb/.
I load them in my .xinitrc with

setxkbmap -I /etc/X11/xkb -print -rules myrules us colemak | xkbcomp -I/etc/X11/xkb - $DISPLAY

By and large, this works well enough, but there are some rough edges that I want to smooth out.

First, you might notice the apparently useless use of xkbcomp. This is, as far as I can tell, the recommended way to load XKB configs which the server doesn't know about.

setxkbmap(1) wrote:

USING WITH xkbcomp
       If  you  have  an Xserver and a client shell running on different computers and some XKB configuration files on those machines are different, you can
       get problems specifying a keyboard map by model, layout, and options names.  This is because setxkbmap converts its arguments to names of XKB config‐
       uration  files according to files that are on the client-side computer, then sends these file names to the server where xkbcomp has to compose a com‐
       plete keyboard map using files which the server has.  Thus if the sets of files differ in some way, the names that setxkbmap generates can  be  unac‐
       ceptable on the server side.  You can solve this problem by running the xkbcomp on the client side too.  With the -print option setxkbmap just prints
       the file names in an appropriate format to its stdout and this output can be piped directly to the xkbcomp input.  For example, the command

       setxkbmap us -print | xkbcomp - $DISPLAY

       makes both steps run on the same (client) machine and loads a keyboard map into the server.

This section specifically mentions mismatched configuration files, but suggests this should only be a problem when the server and client are on separate machines.

Naturally, I searched for a way to tell the Xorg server about /etc/X11/xkb/ since I run both the server and client on the same computer.
The closest things I found were the XkbDir xorg.conf line and the related -xkbdir command-line option.
Both of these completely override the default XKB configuration search path, which I don't want since my configs depend on the system configs too.

Second, you might think "but if this works, why change it?"
Well, any time the keyboard disconnects from my computer (either physically or reset), the configuration is lost and I have to manually run the command at the top of the post.
This is annoying and ideally shouldn't happen.
I suspect this is caused by the server not knowing about the configs, and using a default one whenever a keyboard is connected.

I could instead add my configs to /usr/share/X11/xkb/, but this would make my changes vulnerable to being overwritten by an update.
I could instead make an easily-reachable keybind to run the command, but... eeh.

I see four options from here:

  • Finding a way to hook onto a "keyboard add" event within the X session, to run the command;

  • Finding a way to safely merge my configs with the system ones;

  • Finding a way to give the Xorg server an XKB configuration include path; (possibly adding this feature if it doesn't exist?)

  • Giving up and just making the keybind.

I've been suggested to make a udev rule to run the command whenever I plug in a keyboard, but this runs outside the X session, so I found it hard to implement and I want to go through the other options first.

Does anyone have any pointers or suggestions?

Last edited by AstroSnail (2019-08-02 08:45:51)

Offline

#2 2019-07-31 17:27:53

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: [SOLVED] Is there a way to include a custom XKB configuration path?

You can use xplugd to run commands on xorg hotplug events.

You could also use a custom XkbDir and OverlayFS to merge the directory trees.

No default entries for xkb settings should start with an underscore, so you could simply use an underscore for all of your custom elements and store them in the default directory.

By the way, wayland compositors that rely on libxkbcommon read "~/.xkb/" in addition to "/usr/share/X11/xkb/".

Last edited by progandy (2019-07-31 17:36:30)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#3 2019-07-31 23:49:35

AstroSnail
Member
Registered: 2019-07-31
Posts: 2

Re: [SOLVED] Is there a way to include a custom XKB configuration path?

Thanks! xplugd was exactly what I needed.

I also took the time to try out the overlayfs method, and came to the conclusion that telling Xorg what XKB configs to use was the wrong approach.

Thanks again. smile

Offline

#4 2019-08-01 13:10:19

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: [SOLVED] Is there a way to include a custom XKB configuration path?

Please remember to mark your thread [SOLVED] (edit the title of your first post).

Offline

Board footer

Powered by FluxBB