Using udev to trigger events in example

Find device (this works only with input devices):

Use the name to find system path of the device:

Make a test run:

Look data that is specific to device you want to customize. ID_TYPE=hid is too general, but perhaps ID_VENDOR_ID or ID_MODEL_ID. Sometime there is some tip about device type like ID_INPUT_TOUCHPAD=1. If the data seems too general, it may be better to attach to parent device, run the command again without the last “event” part:

Still, try to find something as close to the end of the chain as possible. Another way worth of trying is to run udevadm info:

Finding the right filter rules seems to be always most difficult for me… Create a new file in /etc/udev/rules.d starting with 2-digit number (this is rule’s priority, I suggest a large one to keep the rule close to the end of the chain). My rules for detecting a Apple Bluetooth keyboard and  a touchpad are:

So I’m using Bluetooth address for keyboard and ID_INPUT_TOUCHPAD for the touchpad. When it is added to system, a script “send-command” will be run. After editing the file, save it and run the udevadm test again:

Check the run command is there. If not, change the rules and try again. If it worked, run one last command to inform the udev daemon about the changes:

That’s it. Now it’s up to you to write the event handlers.