keyboardx11xvfb

How to add keyboard layouts to xvfb?


What's the config file to add keyboard layouts to xvfb (for example fr)?

$ xvfb-run setxkbmap -print -verbose 10
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+inet(evdev)
geometry:   pc(pc105)
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us+inet(evdev)"     };
        xkb_geometry  { include "pc(pc105)"     };
};

I've tried to run commands inside that X:

setxkbmap -layout us,fr -print -verbose 10

It shows the correct one, but it isn't actually applied and doesn't show anymore when printing again.

The /etc/X11/xorg.conf.d/00-keyboard.conf doesn't have any effect either:

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us,fr"
EndSection

Solution

  • Looks like "servers regenerate the keymap when the last client disconnects" (RE: Xvfb and xkb - achandra@ - Xorg mailing lists).

    So after the client has connected run inside the xvfb:

    setxkbmap us,fr -print | xkbcomp - $DISPLAY
    

    It sets and prints the xkb_keymap, passes it to the keymap compiler that then builds it and applies it to the xvfb server.