zen-tools / gxkb

πŸ‡ΊπŸ‡¦ πŸ‡΅πŸ‡± πŸ‡±πŸ‡Ή πŸ‡ͺπŸ‡ͺ X11 keyboard indicator and switcher
https://zen-tools.github.io/gxkb
136 stars 11 forks source link

Layout switching stops working when connecting bluetooth headphones. #45

Closed ogost closed 4 months ago

ogost commented 4 months ago

Not sure if it's related to gxkb or xorg. When bluetooth headphones are connected, layout switching stops working altogether. My configuration is as follows:

group_policy=2
default_group=0
never_modify_config=false
model=pc105
layouts=us,mn
variants=
toggle_option=grp:caps_toggle,grp_led:caps
compose_key_position=

Debian 12, awesomeWM, gxkb v0.9.3, installed from Debian repositories. My xorg.d folder contains this configuration:

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "Tapping" "on"
EndSection

But I suppose this is not related. I suspect that media control buttons present on the bluetooth headphones are recognized by the xorg(or any other part of the system) as a separate input device and it reconfigures layouts disregarding gxkb's config. Any workarounds? Please feel free to close this issue if it's unrelated to gxkb. UPD fixed formatting

zen-tools commented 4 months ago

Yeah, it's unclear if this issue is related to gxkb. Usually, when you connect a new keyboard to a PC, gxkb applies the same configuration to the new one. Otherwise, they will have different keyboard layouts. But that should not affect already connected keyboards, and thus it's unclear what can cause a bug like that.

You can check first if the keyboard config was somehow changed by executing the command setxkbmap -query. And maybe there will be something related in the ~/.xsession-errors and /var/log/Xorg.0.log log files.

Regarding workarounds, you can configure the keyboard layout on the Xorg level. Something like that could be added to xorg.d:

Section "InputClass"
        Identifier  "keyboard"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver          "evdev"
        Option          "XkbModel"      "evdev"
        Option          "XkbLayout"     "us,mn"
        Option          "XkbVariant"    ","
        Option          "XkbOptions"    "grp:caps_toggle,grp_led:caps"
EndSection

And then set never_modify_config=true in the ~/.config/gxkb/gxkb.cfg file, so gxkb will always use Xorg's keyboard settings and ignore model/layouts/variants/toggle_option/compose_key_position.

zen-tools commented 4 months ago

I searched a bit and found a similar issue in other environments. In theory, if you have the gnome-settings-daemon or some other DE-related settings daemon running, it may cause a similar issue because it also has its own keyboard configuration, which by default is 'us'. And, like gxkb, it also tries to change the keyboard's settings, so there may be some race condition.

If it's your case, you may check the answer at the following URL and try to fix the keyboard settings via dconf-editor.

https://unix.stackexchange.com/a/466917

ogost commented 4 months ago

Thank you for your support. I do not have gnome-settings-daemon installed.

Checked logs and found this in /var/log/Xorg.0.log when connecting bluetooth headphones:

[   265.630] (II) config/udev: Adding input device TWS (AVRCP) (/dev/input/event16)
[   265.630] (**) TWS (AVRCP): Applying InputClass "libinput keyboard catchall"
[   265.630] (II) Using input driver 'libinput' for 'TWS (AVRCP)'
[   265.630] (**) TWS (AVRCP): always reports core events
[   265.630] (**) Option "Device" "/dev/input/event16"
[   265.632] (II) event16 - TWS (AVRCP): is tagged by udev as: Keyboard
[   265.632] (II) event16 - TWS (AVRCP): device is a keyboard
[   265.633] (II) event16 - TWS (AVRCP): device removed
[   265.656] (**) Option "config_info" "udev:/sys/devices/virtual/input/input35/event16"
[   265.656] (II) XINPUT: Adding extended input device "TWS (AVRCP)" (type: KEYBOARD, id 14)
[   265.656] (**) Option "xkb_model" "pc105"
[   265.656] (**) Option "xkb_layout" "us"
[   265.656] (WW) Option "xkb_variant" requires a string value
[   265.656] (WW) Option "xkb_options" requires a string value
[   265.659] (II) event16 - TWS (AVRCP): is tagged by udev as: Keyboard
[   265.659] (II) event16 - TWS (AVRCP): device is a keyboard
[   268.592] (II) event16 - TWS (AVRCP): device removed
[   268.628] (II) config/udev: removing device TWS (AVRCP)
[   268.629] (II) UnloadModule: "libinput"
[   269.238] (II) config/udev: Adding input device TWS (AVRCP) (/dev/input/event16)
[   269.238] (**) TWS (AVRCP): Applying InputClass "libinput keyboard catchall"
[   269.238] (II) Using input driver 'libinput' for 'TWS (AVRCP)'
[   269.238] (**) TWS (AVRCP): always reports core events
[   269.238] (**) Option "Device" "/dev/input/event16"
[   269.240] (II) event16 - TWS (AVRCP): is tagged by udev as: Keyboard
[   269.240] (II) event16 - TWS (AVRCP): device is a keyboard
[   269.241] (II) event16 - TWS (AVRCP): device removed
[   269.256] (**) Option "config_info" "udev:/sys/devices/virtual/input/input36/event16"
[   269.256] (II) XINPUT: Adding extended input device "TWS (AVRCP)" (type: KEYBOARD, id 14)
[   269.256] (**) Option "xkb_model" "pc105"
[   269.256] (**) Option "xkb_layout" "us"
[   269.256] (WW) Option "xkb_variant" requires a string value
[   269.256] (WW) Option "xkb_options" requires a string value
[   269.259] (II) event16 - TWS (AVRCP): is tagged by udev as: Keyboard
[   269.259] (II) event16 - TWS (AVRCP): device is a keyboard

Looks like the issue is related to xorg. Will try out your workaround and report back later. For what it's worth, tried to connect an external keyboard just for kicks, everything works as intended, layout switching works just fine on both keyboards.

ogost commented 4 months ago

The workaround you provided works perfectly, thank you. Closing this issue as it is resolved