When using a USB keyboard/mouse on my laptop, I found that if I started typing after a few seconds of not using the keyboard, it would drop the first few keys that I pressed. This is due to USB power saving being enabled on my laptop: USB devices are automatically suspended on inactivity.
Solutions to this problem online generally involve disabling USB power saving completely. That would be a very blunt solution and would hurt battery life. I want to keep the power-saving behavious for all devices excluding input-devices, so I can get a decent battery life, but without the dropped input events.
Initially, I used lsusb to get vendor/product codes for my Das Keyboard and mouse, then started adding udev rules for the devices. This was too precise a solution though, it would only affect my particular model of keyboard and mouse.
I wrote more general rules instead, to disable power saving for any input device:
/etc/udev/rules.d/92-usb-input-no-powersave.rules ------------------------------------------------- ACTION=="add", SUBSYSTEM=="input", TEST=="power/control", ATTR{power/control}="on"
This rule just says “when a device is added, if it’s an input device and it has a «power/control» node in sysfs, write «on» to that node” – a value of “on” (in contrast to “auto”) for this node will result in power saving (notable autosuspend) being disabled.
Problem solved 🙂