I set my keyboard layout to a customized one, with setxkbmap
. It is started with "Autostart Application"(~/.config/autostart
) and is working fine.
But when I plug in my Jabra headphone, it is reset to default US QWERTY one. I want to stop that.
I see another post
How to set xinput properties triggered by udev device connection?
Prevent keyboard layout reset when USB keyboard is plugged in
but the best answer assumes that the OP just plugs in another new keyboard; I think this is a wrong assumption and this is definitely not my case.
I understand it is an udev
problem, and a quite bad bug. Ubuntu 18.04.
Using udevadm monitor
, I see these lines when Jabra headphone is plugged in:
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[514.356707] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2 (usb)
KERNEL[514.360571] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0 (usb)
KERNEL[514.384326] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1 (sound)
KERNEL[514.384427] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1/pcmC1D0p (sound)
KERNEL[514.384485] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1/pcmC1D0c (sound)
KERNEL[514.384542] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1/controlC1 (sound)
KERNEL[514.384584] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0 (usb)
KERNEL[514.384616] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.1 (usb)
KERNEL[514.384645] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.1 (usb)
KERNEL[514.384675] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.2 (usb)
KERNEL[514.384701] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.2 (usb)
KERNEL[514.384730] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3 (usb)
KERNEL[514.387245] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B (hid)
KERNEL[514.387575] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B/input/input18 (input)
KERNEL[514.444127] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B/input/input18/event6 (input)
KERNEL[514.444169] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B/input/input18/input18::mute (leds)
KERNEL[514.444318] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/usbmisc/hiddev0 (usbmisc)
KERNEL[514.444375] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B/hidraw/hidraw1 (hidraw)
KERNEL[514.444438] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B (hid)
KERNEL[514.444473] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3 (usb)
KERNEL[514.444510] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2 (usb)
UDEV [514.967946] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2 (usb)
UDEV [514.970785] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0 (usb)
UDEV [514.971920] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.1 (usb)
UDEV [514.972737] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.2 (usb)
UDEV [514.973022] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3 (usb)
UDEV [514.973854] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1 (sound)
UDEV [514.974449] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.1 (usb)
UDEV [514.975643] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.2 (usb)
UDEV [514.976113] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B (hid)
UDEV [514.976909] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/usbmisc/hiddev0 (usbmisc)
UDEV [514.979273] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B/hidraw/hidraw1 (hidraw)
UDEV [514.980161] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1/pcmC1D0c (sound)
UDEV [514.980666] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B/input/input18 (input)
UDEV [514.980736] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1/pcmC1D0p (sound)
KERNEL[514.980866] change /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1 (sound)
UDEV [514.983803] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B/input/input18/input18::mute (leds)
UDEV [515.017334] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B/input/input18/event6 (input)
UDEV [515.019498] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3/0003:0B0E:0305.000B (hid)
UDEV [515.020828] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.3 (usb)
UDEV [515.790142] add /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1/controlC1 (sound)
UDEV [515.792199] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0 (usb)
UDEV [515.794039] bind /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2 (usb)
UDEV [515.796084] change /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/sound/card1 (sound)
And after it, with xinput list
, I see:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ HP HP USB 1000dpi Laser Mouse id=8 [slave pointer (2)]
⎜ ↳ Chicony HP Business Slim Keyboard Consumer Control id=13 [slave pointer (2)]
⎜ ↳ PS/2 Generic Mouse id=18 [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)]
↳ Sleep Button id=7 [slave keyboard (3)]
↳ Chicony HP Business Slim Keyboard id=10 [slave keyboard (3)]
↳ Chicony HP Business Slim Keyboard System Control id=11 [slave keyboard (3)]
↳ Chicony HP Business Slim Keyboard id=12 [slave keyboard (3)]
↳ Integrated_Webcam_FHD: Integrat id=14 [slave keyboard (3)]
↳ Integrated_Webcam_FHD: Integrat id=15 [slave keyboard (3)]
↳ Dell WMI hotkeys id=16 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=17 [slave keyboard (3)]
↳ Chicony HP Business Slim Keyboard Consumer Control id=19 [slave keyboard (3)]
↳ GN Netcom A/S Jabra EVOLVE LINK MS id=9 [slave keyboard (3)]
Chicony HP Business Slim Keyboard
is my USB keyboard that I want to set layout, and GN Netcom A/S Jabra EVOLVE LINK MS
is the headphone.
setxkbmap
is used and honored by Xserver, by the letterx
in the name.. – WesternGun Apr 13 '21 at 07:58setxkbmap
, you bypass it. Unfortunately the desktop environment also reacts to keyboard hot-plug events, and it does its own equivalent ofsetxkbmap
, to the best of its knowledge... but if you have done your ownsetxkbmap
behind its back, it'll end up setting the wrong keyboard layout. – telcoM Apr 13 '21 at 10:01