Generate a New udev Rule¶
Get Info on a Device¶
udevadm info --name=${dev_node} --attribute-walk
Produce Rule¶
ACTION=="add", ENV{ID_VENDOR_ID}=="2c7c", ENV{ID_MODEL_ID}=="0125", ATTRS{bInterfaceNumber}=="03", SYMLINK+="ec25-at"
Tip
The match keys are KERNEL
, SUBSYSTEM
, DRIVER
and ATTR
... To match a parent's property too, use the plural, e.g: ATTRS
.
Warning
When matching against parent properties (e.g: using ATTRS
), all parent matches must be valid for a single parent.
Multiple Parents¶
It sounds like it should be possible to use multiple parents, like this... but I couldn't get it to work.
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{ec25}="yes" ACTION=="add", ENV{ec25}=="yes", ATTRS{bInterfaceNumber}=="03", SYMLINK+="ec25-at"
ACTION=="add", SUBSYSTEM=="tty", KERNELS=="1-2", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="cr10-v3"
Reload Rules¶
udevadm control --reload-rules udevadm trigger
Test Rule¶
dev_path="$( udevadm info -q path -n ${dev_node} )" action="add" udevadm test -a "${action}" "${dev_path}"
Tip
udevadm test
gives you a list of the environment variables that are available!