3

I often connect a USB keyboard to my laptop, and when I plug it in, the default repeat rate is not what I want. I tried changing it using a udev script by adding a rule

`ACTION=="add", ATTRS{name}=="Dell Dell Multimedia Pro Keyboard", RUN+="set-keyboard.sh"`

with the set-keyboard.sh script calling

xset -display :0 r rate 500 50; xset -display :0 b off

The problem is that this sets the repeat rate and beep of the laptop built-in keyboard, not the USB keyboard. (That is, if I type xset q on the built-in keyboard, it shows the right settings, but if I type xset q on the USB keyboard, it's still set to the wrong rate.)

Is there a way to let xset know which keyboard to set, or some other way to go about this?

  • 1
    Have you tried being more selective in your udev rule? Like using the vendor and product id in the selection part of the rule? – lgeorget Aug 4 '13 at 21:09
2

After some poking around, I found from https://bugzilla.redhat.com/show_bug.cgi?id=601853 that the issue may be that xorg resets the keyboard rate after udev has run, so even though my udev script was definitely being executed, its actions were promptly undone by xorg.

However, that page also has the fix: if I run startx with the options startx -- -ardelay 500 -arinterval 20, then my settings are preserved even when a new keyboard is plugged in.

  • Having the same issue. Any way to integrate your fix into xorg.conf? – amphetamachine Feb 4 '15 at 15:22
1

You can try this command to determine what the udev ID would be for your USB keyboard. Run this and then plug your keyboard in:

$ udevadm monitor --udev --subsystem-match=usb

Example - monitor

I have an old Sun Microsystems USB keyboard. When I unplug it and plug it back in I get the following udev messages:

$ udevadm monitor --udev --subsystem-match=usb
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing

UDEV  [1375655040.466080] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
UDEV  [1375655040.557791] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
UDEV  [1375655044.586242] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
UDEV  [1375655044.589087] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
UDEV  [1375655049.880514] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
UDEV  [1375655049.905175] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)

So the udev ID you could put into your rule would make use of this piece of the above output, /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2.

Example - export

You can also just export the entire udev DB and manually scan through it:

$ udevadm info --export-db
...
P: /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2
N: bus/usb/002/009
S: char/189:136
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2
E: SUBSYSTEM=usb
E: DEVNAME=bus/usb/002/009
E: ID_VENDOR=0430
E: ID_VENDOR_ENC=0430
E: ID_VENDOR_ID=0430
E: ID_MODEL=0005
E: ID_MODEL_ENC=0005
E: ID_MODEL_ID=0005
E: ID_REVISION=0102
E: ID_SERIAL=0430_0005
E: ID_BUS=usb
E: ID_USB_INTERFACES=:030101:
E: MAJOR=189
E: MINOR=136
E: DEVTYPE=usb_device
E: DRIVER=usb
E: DEVICE=/proc/bus/usb/002/009
E: PRODUCT=430/5/102
E: TYPE=0/0/0
E: BUSNUM=002
E: DEVNUM=009
E: DEVLINKS=/dev/char/189:136
...

And make use of some other unique characteristic from the above output in your udev rule too.

References

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.