Jump to content

udev problems [REOPENED]


Steve Scrimpshire
 Share

Recommended Posts

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 by Steve Scrimpshire
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...