View previous topic :: View next topic |
Author |
Message |
no_hope Guru
Joined: 23 Jun 2003 Posts: 482
|
Posted: Sun Feb 19, 2006 1:59 am Post subject: [SOLVED] Running custom script when USB device plugs in |
|
|
I would like to run a certain script I wrote when a USB device (wireless card) is plugged in (i.e. I need to handle an "add" event). I tried using usbd and hotplug but I couldn't make sense of them. Can anybody help?
edit: I am stupid.
Here's what to do with hotplug:
put the script you want to run into /etc/hotplug/usb/ (don't forget to make it executable).
edit /etc/hotplug/usb.usermap:
Code: |
# usb module match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info
dwl-122-wlan0-tsunami.sh 0x0003 0x2001 0x3700 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
|
The first (very long) line shows possible fields to match when a device is inserted. First item on the second line is the script you want to run. The second is the bitmap where bits corresponding to the fields you want to match are set. In my case I run dwl-122-wlan0-tsunami.sh when a device whose vendor id is 0x2001 and product id is 0x3700 is inserted.
Also see http://www.wlug.org.nz/HotPlugNotes
Last edited by no_hope on Sun Feb 19, 2006 2:48 am; edited 1 time in total |
|
Back to top |
|
|
rada Apprentice
Joined: 21 Oct 2005 Posts: 202 Location: Ottawa, Canada
|
Posted: Sun Feb 19, 2006 2:46 am Post subject: |
|
|
How do you make it executable? |
|
Back to top |
|
|
no_hope Guru
Joined: 23 Jun 2003 Posts: 482
|
Posted: Sun Feb 19, 2006 2:49 am Post subject: |
|
|
rada wrote: | How do you make it executable? |
The usual way: chmod +x <script name> |
|
Back to top |
|
|
|