Here is a rule from my /lib/udev/rules.d directory:
SUBSYSTEM=="input", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="008c", RUN+="/home/mikeknoop/scripts/udev-receiver.sh"
Here is the simple contents of the udev-receiver.sh script:
#!/bin/bash
echo "UDEV-RECEIVER INIT" >> /var/log/external.log
{
sleep 5;
echo "Done" >> /var/log/external.log
} &
echo "UDEV-RECEIVER FINISH" >> /var/log/external.log
When I plug in my device, the output of external.log is as you would expect:
UDEV-RECEIVER INIT
UDEV-RECEIVER FINISH
Done
However, I am also tailing the syslog /var/log/syslog and can see that even though I have forked the long-running sleep process, udev device initialization is blocking until after Done shows up in my external.log file.
The reason this is important is because I am trying to set some device properties via xinput but the device isn't listed via xinput list until the entire udev initialization is completed (until after Done shows up in external.log).
According to the udev(7) - Linux man page
"Add a program to the list of programs to be executed for a specific device. This can only be used for very short running tasks. Running an event process for a long period of time may block all further events for this or a dependent device. Long running tasks need to be immediately detached from the event process itself."
I am unable to reconcile the man page and the behavior that I am seeing. Can anyone shed light or offer a better way to set properties via xinput when a device is inserted?
Thanks!