X11 pairing setup with two different keyboard layouts

We're pairing! Like - almost all the time. I'm really enjoying it, but as we tend to not always pair on the same machine, it takes time until the setup converges to some standard which is accepted by every potential pairing partner.

 

One of the most annoying things I've encountered is keyboard layout switching. Like 80% of the time that you switch from the driver- to the navigator-seat, or vice versa, you forget to (use some arbitrary, machine-dependent non-automatism to) switch the keyboard layout back to what it used to be before. This can range from varying keyboard shortcuts (Alt+Shift+Ctrl+F1+F12+CAPS+F) to raw setxkbmap calls.

 

Long story short - use the power of X11 to set a keyboard layout per connected keyboard, and enjoy the whole pairing session without a "WTFIHATEYOURMACHINE!" once!


DISCLAIMER: stop your energy pointing me to udev! kthxbye.

1. Find your keyboards

xinput will give you all connected input devices. Find your keyboards and write down the associated ids. In my case, these are id=10 and id=11. Also note that both keyboards have the same usb major and minor (046a:0011), which makes further automation rather hard due to missing uniqueness. If you have two different keyboards, you can automate the next step based on the usb ids.

[zined@wurstbrot ~]$ xinput -list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech USB-PS/2 Optical Mouse           id=12   [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=14   [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                     id=15   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    ↳ Integrated Camera                         id=9    [slave  keyboard (3)]
    ↳ HID 046a:0011                             id=10   [slave  keyboard (3)]
    ↳ HID 046a:0011                             id=11   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=13   [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                    id=16   [slave  keyboard (3)]
[zined@wurstbrot ~]$ 

2. Set a layout per device

Now that we know the ids of our keyboards, simply use setxkbmap to set two different layouts for your keyboards.

[zined@wurstbrot ~]$ setxkbmap -device 10 de
[zined@wurstbrot ~]$ setxkbmap -device 11 en_US
[zined@wurstbrot ~]$ 

3. Enjoy pairing


Kommentar schreiben

Kommentare: 0