0

This question already has an answer here:

Hate to ask this sort of question, but...

Device info: udevadm monitor --env

UDEV  [3048.530438] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6.3 (usb)
ACTION=remove
BUSNUM=002
DEVNAME=/dev/bus/usb/002/079
DEVNUM=079
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6.3
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=Corsair_K95_RGB_Gaming_Keyboard
ID_MODEL_ENC=Corsair\x20K95\x20RGB\x20Gaming\x20Keyboard\x20
ID_MODEL_ID=1b11
ID_REVISION=0204
ID_SERIAL=Corsair_Corsair_K95_RGB_Gaming_Keyboard_0F012009AE3B9405537541A6F5001942
ID_SERIAL_SHORT=0F012009AE3B9405537541A6F5001942
ID_USB_INTERFACES=:030101:030000:
ID_VENDOR=Corsair
ID_VENDOR_ENC=Corsair
ID_VENDOR_FROM_DATABASE=Corsair
ID_VENDOR_ID=1b1c
MAJOR=189
MINOR=206
PRODUCT=1b1c/1b11/204
SEQNUM=5028
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=2983373870

Udev rules:

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1b1c", ATTRS{idProduct}=="1b11", RUN+="/home/user/.scripts/switch", OWNER="user"
ACTION=="remove", SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="1b1c", ENV{ID_MODEL_ID}=="1b11", RUN+="/home/user/.scripts/switch", OWNER="user"

I was trying to follow this: How to run custom scripts upon USB device plug-in?

And this: https://wiki.archlinux.org/index.php/Udev#Writing_udev_rules

To create my rules and after a little help I found out that I needed to add a subsystem statement and lowercase device and vendor IDs (were uppercase). this fixed up my "add" rule, but my "remove" rule is not working, just about the only thing I can find online about how to correct it is that I should use ENV rather than ATTRS for this, and so I do, but it does not work. I also tried using ENV{ID_MODEL} as was often suggested but it worked no better.

What do I do?

marked as duplicate by Cestarian, Community Jun 18 '16 at 21:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    all the examples use lowercase hex for idVendor and idProduct attributes, so perhaps you can try that. – meuh Jun 18 '16 at 18:02
  • @meuh this worked (had faulty testing approach) however it only worked for the "add" action, I made sure the lines are identical by copying the add line, then pasting it and changing "add" to "remove" after I confirmed that this worked, this was not the only change I made (I also added SUBSYSTEM=="usb") But yeah, having problems with the remove action still. – Cestarian Jun 18 '16 at 20:00

Browse other questions tagged or ask your own question.