1

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.

2 Answers2

1

Your Jabra earphone apparently includes some buttons that are presented to the OS as a "keyboard-like" input device, and apparently your desktop environment will reset the X11 keyboard layout whenever new keyboard devices are plugged in, according to the settings it knows about.

Your setxkbmap settings will not be known to the desktop environment, and so the desktop environment and the setxkbmap will end up fighting with each other.

Instead of using setxkbmap, you should use the configuration tools of your desktop environment to have it set your keyboard correctly in the first place. Unfortunately the Gnome desktop seems to only offer a simplified keyboard layout selector GUI: but you should still be able to put the settings directly to /etc/default/keyboard. See man 5 keyboard for more details.

telcoM
  • 96,466
  • Yes I confirm that this earphone has some volume adjust buttons and so on. OK I will try that. I thought setxkbmap is used and honored by Xserver, by the letter x in the name.. – WesternGun Apr 13 '21 at 07:58
  • The desktop environment is an additional layer on top of the Xserver, and by using setxkbmap, you bypass it. Unfortunately the desktop environment also reacts to keyboard hot-plug events, and it does its own equivalent of setxkbmap, to the best of its knowledge... but if you have done your own setxkbmap behind its back, it'll end up setting the wrong keyboard layout. – telcoM Apr 13 '21 at 10:01
  • Hm... When I change default keyboard file, it changes the layout before login, ok. But when I plug in my earphone, it is reset again..? I don't get it. And even when it is plugged out, the keyboard layout is still QWERTY. – WesternGun Apr 13 '21 at 17:58
  • I don't think it's Ubuntu problem. Have you tried disconnectiong your desktop keyboard , plugging in your buds and then reconnecting your keyboard? It's possible the last device to be plugged in is the decider. At least it may indicate it's not Ubuntu problem. Also, have tried contacting support at Jabra Direct? – Cinaed Simson Apr 13 '21 at 20:45
  • Hi @CinaedSimson, yes I tried to unplug my keyboard, and plug in my headphone, and reconnect my keyboard. Same: layout changed. – WesternGun Apr 19 '21 at 08:14
  • Okay. In the following: "GN Netcom A/S Jabra EVOLVE LINK MS" the "MS denotes MIcrosoft. Evidently, you have the wrong firmware loaded in the headset? My second guess is you need to contact Jabra support about upgrading the firmware. Since there are no LInux clients, you'll most likely need MaOS or Window to upgrade the firmware on the headset - or maybe Wine might work. – Cinaed Simson Apr 20 '21 at 06:07
0

I fixed that by setting the keyboard layout using Gnome's dialog while the headphones were connected. Somehow when they were connected, Gnome just considered no layout is set at all.

Once set - it kept my layout regardless of if headphones are connected or not.

dulek
  • 11
  • How lucky you are! I use a customized keyboard layout which only works with setxkbmap, and Gnome dialog does not help me. – WesternGun Dec 15 '21 at 08:28
  • Hah, me too. :D Try toggling org/gnome/desktop/input-sources/show-all-sources in dconf to make the setting dialog show every layout. Or use Gnome Tweaks and switch it on in Keyboard & Mouse settings. – dulek Dec 15 '21 at 15:03
  • I tried but still cannot see it. My keyboard layout is defined with a text file under /usr/share/X11/xkb/symbols/. Which part of this file dictates what language it belongs to? I may have missed it, but I don't see it. – WesternGun Dec 15 '21 at 15:44
  • 1
    Mine seems to be there too. Anyway if so why don't you try to set it manually in dconf then? In /org/gnome/desktop/input-sources/sources I have [('xkb', 'pl+intl')] set and it works. – dulek Dec 16 '21 at 08:33
  • I have [('ibus', 'rime')] (rime is an input method under ibus, which converts pinyin into Chinese characters; when input methods are involved things get complicated so I am not sure) – WesternGun Dec 17 '21 at 08:41