I'm trying to set xinput properties for a USB input device whenever it is connected. I have seen solutions that require a script to run in the background and poll USB devices, but I would like to find a triggered approach rather than one involving user-space polling.

I have tried creating a udev rule that runs a script on device connection, but it appears that the connected device is not yet visible to xinput when the udev add rule is triggered. This appears to be a constant order of events rather than a race condition as adding a sleep command to the script also delays the device being listed in xinput list.

Is there any reliable method of setting xinput properties for devices when they are connected?

  • why trigger them on udev and not on xinput events? the former requires root, it's tricky, system-dependent, and messes with stuff it has not business messing with. The latter could be done be any x11 client, via the xinput or xinput2 extension. Also have a look here.
    – mosvy
    Aug 18 '19 at 8:28

The normal method is to write an xorg.conf file, use the InputClass matching methods, and set properties directly in xorg.conf. No script, no race condition, no explicit meddling with udev; it just works, though it doesn't use xinput directly...

See man xorg.conf for details.

  • xinput has properties listing, but xorg.conf does not. Is there a way to know the property exact name to be used in xorg.conf?
    – user.dz
    Oct 13 '19 at 22:57
  • Ok, never mind, found it man(4) libinput , have nice time.
    – user.dz
    Oct 14 '19 at 10:35
  • +1 for the clue, but for exactly how-to you must look here: unix.stackexchange.com/questions/58117/…
    – WesternGun
    Apr 14 at 8:08

I had the same problem. My solution was to trigger the udev rule with ACTION=="bind" instead of ACTION=="add" (Because I saw with udevadm monitor that it was last action when I connected a mouse)

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.