[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: udev rule doesn't fire when device is removed



andy baxter wrote:
Hi,

I am trying to get fluidsynth to start and connect itself automatically when a usb midi keyboard is plugged in, and to stop when it is removed. The connecting script works fine, and the rule to trigger when it is plugged in fires OK, but when I remove the device, the rule doesn't trigger again.

The rule I was using is:
ATTR{manufacturer}=="EDIROL", ATTR{product}=="PCR", RUN+="/usr/local/bin/fluidrun"

With this, it detects connections but not disconnections.

I have also tried separating the two rules, like this:

ACTION=="ADD", ATTR{manufacturer}=="EDIROL", ATTR{product}=="PCR", RUN+="/usr/local/bin/fluidrun"
ACTION=="REMOVE", DRIVER=="snd-usb-midi", RUN+="touch /tmp/udevtest"

But the second rule still doesn't fire on removal as I was hoping it would.

Is it normal for udev to use different keys / attributes when a device is removed, and if so then how should I write the appropriate rule for this device?

thanks,

andy baxter.


This is now working, using the rules:

whale:/etc/udev/rules.d# cat 85-fluidsynth-midi.rules
ACTION=="add", ATTR{manufacturer}=="EDIROL", ATTR{product}=="PCR", ENV{edirolmidi}="true", RUN+="/bin/touch /tmp/midiadd"
ACTION=="remove", ENV{edirolmidi}=="true", RUN+="/bin/touch /tmp/midirem"



Reply to: