[LINUX] Key repeat reverts to default when reconnecting bluetooth keyboard


I replaced it with a Bluetooth version of ThinkPad Keyboard at the end of the year, but every time I reconnected bluetooth, the key response speed returned to the default. Putting the xset settings in .xprofile or i3conf and running them at startup didn't improve at all, but I happened to be able to do this yesterday while doing this and that, so make a note of it.

usage environment

bluetooth automatic connection setting

If you have already done so, please skip it. Edit /etc/bluetooth/main.conf as described in the Arch wiki. Uncomment ```AutoEnable = true`` or add a new one.

[Reference: Enable automatically after startup](https://wiki.archlinux.jp/index.php/Bluetooth#.E8.B5.B7.E5.8B.95.E5.BE.8C.E3.81 .AB.E8.87.AA.E5.8B.95.E3.81.A7.E6.9C.89.E5.8A.B9.E3.81.AB.E3.81.99.E3.82.8B)

Set key repeat at startup / after waking from sleep

Device refinement: udev settings

Use udev. Go to /etc/udev/rules.d/, create a 95-xset-input-rules file, and enter the following:

KERNEL=="js0", ACTION=="add", RUN+="/bin/sh -c '/usr/local/sbin/lenovo-keyrepeat'"

Those with "==" such as the first KERNEL and ACTION are search conditions that limit the device here. I think there are various ways to narrow down this, so use ʻudevadm monitor`` or ʻudevadm info`` to narrow down.

Reference site: I wrote udev rules to fix the device name How to write udev rules

By the way, I didn't know how to read the log to see if the filtering was done properly, so I executed the following command with a script.

echo 'test' >> /home/<user>/log

It is a primitive discrimination method that if there is only one line of test when reconnecting, the narrowing down is successful, and if there are two or more, the narrowing down is insufficient.

Command execution

RUN + = Write the following script. I think the location is okay elsewhere, but it needs to be viable.


sleep 1
export XAUTHORITY="/home/<user>/.Xauthority"
export DISPLAY=:0

/usr/bin/xset -display :0 r rate 200 100

If you execute sleep 1 immediately, it may not respond, so wait for a while. It is certain to set it to 3, and it may be better to gradually reduce it. `ʻexport XAUTHORITY merely I was worried for over a week just not putting this in. The following link was helpful.

udev rule to turn on keyboard backlight

To be honest, I'm not sure why this and `ʻexport DISPLAY =: 0`` are needed. Since udev is executed by parent authority, I imagine that it is related to that.


Execute the following command as root.

udevadm control --reload && udevadm trigger

```udevadm control --reload-rules`` seems to be fine.

After reconnecting bluetooth and waiting for a while, the speed has changed. Compared to the built-in keyboard, it's hard to hit immediately, but it's okay because it doesn't bother me that much.

Recommended Posts

Key repeat reverts to default when reconnecting bluetooth keyboard