Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Running custom script when USB device plugs in
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
no_hope
Guru
Guru


Joined: 23 Jun 2003
Posts: 482

PostPosted: Sun Feb 19, 2006 1:59 am    Post subject: [SOLVED] Running custom script when USB device plugs in Reply with quote

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
View user's profile Send private message
rada
Apprentice
Apprentice


Joined: 21 Oct 2005
Posts: 202
Location: Ottawa, Canada

PostPosted: Sun Feb 19, 2006 2:46 am    Post subject: Reply with quote

How do you make it executable?
Back to top
View user's profile Send private message
no_hope
Guru
Guru


Joined: 23 Jun 2003
Posts: 482

PostPosted: Sun Feb 19, 2006 2:49 am    Post subject: Reply with quote

rada wrote:
How do you make it executable?

The usual way: chmod +x <script name>
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum