Steve Scrimpshire Posted December 29, 2006 Report Share Posted December 29, 2006 (edited) I added two rules to my /etc/udev/rules.d/70-hotplug_map.rules file: SUBSYSTEM=="usb_device", ACTION=="add", SYSFS{idVendor}=="0781", SYSFS{idProduct}=="7411", RUN+="/home/ohms/bin/thumb" SUBSYSTEM=="usb_device", ACTION=="remove", SYSFS{idVendor}=="0781", SYSFS{idProduct}=="7411", RUN+="/home/ohms/bin/remove" The problem is it runs the ACTION=="add" but not the ACTION=="remove" script. How exactly can I run a script when I attach my mp3 player and a different script when I remove it? Solution: Instead of using /etc/udev/rules.d/70-hotplug_map.rules, use /etc/udev/rules.d/60-dynamic.rules and instead of SUBSYSTEM=="usb_device", ACTION=="add", SYSFS{idVendor}=="0781", SYSFS{idProduct}=="7411", RUN+="/home/ohms/bin/thumb" SUBSYSTEM=="usb_device", ACTION=="remove", SYSFS{idVendor}=="0781", SYSFS{idProduct}=="7411", RUN+="/home/ohms/bin/remove" I had to use: KERNEL=="sda[0-9]*", ACTION=="add", RUN+="/home/ohms/bin/thumb" KERNEL=="sda[0-9]*", ACTION=="remove", RUN+="/home/ohms/bin/remove" I wish I could do it with SYSFS{blech} though, so it would be specific to my mp3 player and not just any thumb drive. Edited December 30, 2006 by Steve Scrimpshire Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.