-
Notifications
You must be signed in to change notification settings - Fork 116
Keyboard repeat settings ignored when USB keyboard attached #808
Description
Distribution
Debian 13, Linux version 6.12.69+deb13-amd64
Package version
Cinnamon 6.4.10
Graphics hardware in use
NVIDIA Corporation GP108 [GeForce GT 1030]
Frequency
Always
Bug description
When a USB keyboard is disconnected and reconnected*, it will 'forget' the users key repeat settings (repeat, delay, repeat-interval) and use the default settings instead.
This persists until any of the key repeat options are changed - either with the graphical menu, or using CLI commands e.g. :
gsettings set org.cinnamon.desktop.peripherals.keyboard repeat false
gsettings set org.cinnamon.desktop.peripherals.keyboard repeat true
running the above will restore the users delay and delay-interval settings.
*Disabling and reenabling the USB root hub will also cause this issue. Other people have also reported it happening when unplugging a hub, if the keyboard is connected via that hub.
Steps to reproduce
Manual method:
- Plug in the USB keyboard.
- Hold down a key on the keyboard, and observe how fast the key repeats.
- Change the repeat settings.
gsettings set org.cinnamon.desktop.peripherals.keyboard repeat false
gsettings set org.cinnamon.desktop.peripherals.keyboard repeat true
gsettings set org.cinnamon.desktop.peripherals.keyboard delay 210
gsettings set org.cinnamon.desktop.peripherals.keyboard repeat-interval 20
- Hold down a key on the keyboard. The keys should repeat much faster.
- Unplug the USB keyboard.
- Plug in the USB keyboard.
- Hold down a key on the keyboard. Observe the same speed as in step 2.
- Change repeat settings to the same value
gsettings set org.cinnamon.desktop.peripherals.keyboard delay 210
- Hold down a key on the keyboard. Observe the same speed as in step 7.
- Change repeat settings to a different value.
gsettings set org.cinnamon.desktop.peripherals.keyboard delay 211
- Hold down a key on the keyboard. Observe the same speed as in step 4.
done.
Script to automate 'unplugging the keyboard'
This script resets all USB root hubs, which will also cause this issue. Running this script can replace steps 5 & 6 in the procedure above; useful for testing.
#!/usr/bin/env bash
# Resets all USB host controllers of the system.
# This is useful in case one stopped working
# due to a faulty device having been connected to it.
base="/sys/bus/pci/drivers"
sleep_secs="0.1"
# This might find a sub-set of these:
# * 'ohci_hcd' - USB 3.0
# * 'ehci-pci' - USB 2.0
# * 'xhci_hcd' - USB 3.0
echo "Looking for USB standards ..."
for usb_std in "$base/"?hci[-_]?c*
do
echo "* USB standard '$usb_std' ..."
for dev_path in "$usb_std/"*:*
do
dev="$(basename "$dev_path")"
echo " - Resetting device '$dev' ..."
printf '%s' "$dev" | sudo tee "$usb_std/unbind" > /dev/null
sleep "$sleep_secs"
printf '%s' "$dev" | sudo tee "$usb_std/bind" > /dev/null
echo " done."
done
echo " done."
done
echo "done."
credit to https://unix.stackexchange.com/a/704342
Keyboard used is a Logitech K120 (M/N YU0042)
output of lsusb -tv
/: Bus 001.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/9p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
|__ Port 004: Dev 004, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 046d:c31c Logitech, Inc. Keyboard K120
|__ Port 004: Dev 004, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 046d:c31c Logitech, Inc. Keyboard K120
Expected behavior
Re-apply the users key repeat settings when a keyboard is plugged in.
Additional information
Issue originally filed against the Cinnamon repository in 2022: linuxmint/cinnamon#11198
While looking for a workaround, I discovered the org.cinnamon.desktop.peripherals.keyboard option. When I searched for that option, it led me to the code in this repository, specifically:
https://github.com/linuxmint/muffin/blob/master/src/backends/meta-input-settings.c#L2019-L2021
https://github.com/linuxmint/muffin/blob/master/src/backends/meta-input-settings.c#L846
... which I believe is setting up an event handler for when that option is changed. That handler eventually leads to input_settings_class->set_keyboard_repeat(), which applies the settings.
Based on that, I'm hoping that filing an issue here will have a better chance of getting the issue fixed.