Can I Run Some Script When My Keyboard Get "Reset"?

My issue is kind of hard to explain. So I use Arch Linux, and possibly Systemd’s udev daemon is causing my keyboard to get reset very often (it seems to be some sort of bug). I don’t use QWERTY layout so it’s kind of a big issue because after it’s reset the settings made by my Xorg’s config files are also gone for my external keyboard. I have spent weeks trying to fix it, but I couldn’t fix it (I have went through Arch Wiki’s several relevant pages) so I’d rather not waste more time on it. Instead I switched from i3wm to Plasma.

Plasma seems to be doing something that does not let me face the consequences of my external keyboard getting reset. It seems like it it actively pushing Xorg to just accept my keyboard’s layout. Unfortunately there is this issue where my caps-lock physical key, which is mapped as my second backspace key (I use Colemak layout), will face a small consequence of these resets: it will not repeatedly trigger backspace if I press and hold the key. This is fixed if you type xset r 66 in the terminal, so I was hoping to automate the process anyhow. Do I have a chance?

Have you setup the Colemak layout correctly?

  • man 7 xkeyboard-config
Layout(Variant)                  Description
us(colemak)                      English (Colemak)
no(colemak)                      Norwegian (Colemak)
gb(colemak)                      English (UK, Colemak)
ph(colemak)                      Filipino (Colemak, Latin)
ph(colemak-bay)                  Filipino (Colemak, Baybayin)

Option              Description
esperanto:colemak   To the corresponding key in a Colemak layout
  • man 1 setxkbmap

Have you chosen the Colemak layout in the KDE System Settings?

Do the files in the directories below ‘/usr/share/X11/xkb/’ contain Colemak layout information?

> grep -Ri 'colemak' /usr/share/X11/xkb/*

Does this happen randomly or when you update your system?

I have also turned on “Make Caps Lock as an additional Backspace” from “Advanced” section.

Yes, everything is as it should be in my system settings of KDE Plasma.

localectl status
System Locale: LANG=en_US.UTF-8
    VC Keymap: us
   X11 Layout: us
    X11 Model: colemak

I have also checked the commands you have mentioned, and I found mentions of Colemak in each just as I would expect. I will mention that even if I do xset r 66 it will randomly get reset again. It just so happens that in i3wm, I lose my layout like this randomly too, but in Plasma I only lose the ability to press and hold my second backspace key (possibly because just applying the layout doesn’t back the physical caps-lock key repeat).

It happens randomly and also when I update my system. My laptop’s internal keyboard works fine (all configurations are preserved), the issue is with my external keyboard.

I will mention that I had to add btusb.enable_autosuspend=0 to my bootloader to fix some disconnection issues with my bluetooth headphones.

I will also mention that these configurations are still active:

crystal :: ~ » cat /etc/udev/rules.d/50-usb_power_save.rules
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="b008", ATTR{power/autosuspend}="-1"
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="10c4", ATTR{idProduct}=="8105", ATTR{power/autosuspend}="-1"

# ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="auto"
# LABEL="power_usb_rules_end"

Where the IDs are:

crystal :: ~ » lsusb
Bus 001 Device 003: ID 0bda:b008 Realtek Semiconductor Corp. Bluetooth Radio
Bus 001 Device 002: ID 0438:7900 Advanced Micro Devices, Inc. Root Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 004: ID 05c8:038f Cheng Uei Precision Industry Co., Ltd (Foxlink) HP TrueVision HD
Bus 002 Device 003: ID 10c4:8105 Silicon Labs USB OPTICAL MOUSE
Bus 002 Device 002: ID 0438:7900 Advanced Micro Devices, Inc. Root Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 1a2c:6003 China Resource Semico Co., Ltd USB Keyboard
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


You could try enabling the Kernel’s “SysRq” keys – for ArchLinux – <>

Then, to regain control over the Keyboard and Mouse type (all three keys together):