I have gone through 10s of answers on this and other sites trying to debug my udev rule, but to no avail. The rule is very simple: I want to lock my screen when my Yubikey is unplugged.
- My rule is in the file /etc/udev/rules.d/98-yubikey.rules.
- I have tried both # udevadm control --reload-rules && udevadm triggerand simply rebooting my computer to update the rules.
Here are the rules I have tried so far, none of which lock the screen (I have tested that the script does, in fact, lock the screen when run).
- ACTION=="remove", SUBSYSTEM=="input", ATTRS{idVendor}=="XXXX", ATTRS{idProduct}=="YYYY", RUN+="/home/user/bin/lock_screen", OWNER="user"
- ACTION=="add", SUBSYSTEM=="input", ENV{ID_VENDOR_ID}=="XXXX", ENV{ID_MODEL_ID}=="YYYY", RUN+="/home/user/bin/lock_screen", OWNER="user"
- Various combinations of these items with or without subsystem/owner (and with subsystem as usb instead of input).

lock_screenscript? How are you trying to run it? The script may need some variables that are not defined when it is run from udev, how are you handling this?