Penguin
Blame: HotPlugNotes
EditPageHistoryDiffInfoLikePages
Annotated edit history of HotPlugNotes version 11, including all changes. View license author blame.
Rev Author # Line
1 JohnMcPherson 1 This page has examples for using the HotPlug package.
7 ZuKim 2
8 ZuKim 3 If your problem is just the "too sensitive touchpad," the best solution is to install a touchpad driver:<br>
4 http://gentoo-wiki.com/HARDWARE_Synaptics_Touchpad<br>
5 http://zuwhan.blogspot.com/2005/09/gentoo-linux.html#touchpad<br>
4 JohnMcPherson 6
7 If you use [GNOME] 2.6 or later, you can install and run gnome-volume-manager, which can do things like run a program when a camera is plugged in, or mount a removable storage device when plugged in.
1 JohnMcPherson 8
9 ----
10 !!![USB]
11 !!"Usermap" files
12 Newer versions of hotplug have a set of "usermap" files in /etc/hotplug/usb. (Older versions of hotplug use a single file named "/etc/hotplug/usb.usermap".) This gives the name of scripts to run for particular USB devices.
13
14 The file format is:
15 name_of_script fields_to_match field1 field2 field3 ... field11
16
17 The "fields_to_match" field is a bitfield - add 1 if you want to match against field1, add 2 if you also want to match against field2, add 4 to match against field3, etc. Only field1 and field2 are really necessary - they correspond to vendor_id and vendor_product_id respectively.
18
19 Here is my usb.usermap:
4 JohnMcPherson 20 <verbatim>
1 JohnMcPherson 21 # kodak dx3900 digital camera
22 usbcam 0x0003 0x040a 0x0170 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
23 # sony dsc p10 digital camera
24 usbcam 0x0003 0x054c 0x004e 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
25 # laser printer
26 brother_hl1440 0x0003 0x04f9 0x000d 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
4 JohnMcPherson 27 </verbatim>
1 JohnMcPherson 28
29 So, when a USB device with vendor ID of 40a and product ID of 170 is inserted, hotplug will run the script named "usbcam" in the /etc/hotplug/usb directory.
30 The 0x0003 tells hotplug to match this rule against only the vendor ID (1) + the product ID (2), ignoring all the other fields. These flags are defined in /etc/hotplug/usb.agent . You can determine the values for your device by looking at your system logs (eg run dmesg(8)) after inserting the [USB] device.
31 If you have the "usbutils" package installed, you could look in the file "/usr/share/misc/usb.ids" or run the "lsusb" command to get a description of connected USB devices.
32
33 See below for notes about the scripts.
34
3 JohnMcPherson 35 ! Notes about editing the usb.usermap file
2 MichaWied 36 In the version of hotplug in [Debian] [Woody], you should add your changes to /etc/hotplug/usb.usermap.local and then run
4 JohnMcPherson 37 <verbatim>
1 JohnMcPherson 38 # update-usb.usermap
4 JohnMcPherson 39 </verbatim>
1 JohnMcPherson 40
41 In more recent versions of hotplug, (such as Debian Testing/Unstable), create files named /etc/hotplug/usb/{foo}.usermap, for each script you have named foo.
42
43
44 !! USB scripts
45 Make sure these scripts are executable! Hotplug will set the following environment variables for use by the scripts:
4 JohnMcPherson 46 <verbatim>
1 JohnMcPherson 47 ACTION {add, remove}
48 DEVICE {name of the usbdevfs device... for example /proc/bus/usb/001/003}
49 DEVFS
50 PRODUCT
51 INTERFACE
52 TYPE
4 JohnMcPherson 53 </verbatim>
1 JohnMcPherson 54 See the /etc/hotplug/usb.agent script for more details.
55
56 Note that many of the script names in .../usb.distmap are actually module names.
57
58 ! Example scripts
59 This is the script run when hotplug detects one of the digital cameras. the gphoto2 package for [DigitalCamera]s comes with its own usbcam script for this purpose, but it sets the [USB] device to be owned by the user that owns /dev/console, which doesn't work under debian. This works fine assuming you are the only person on your computer, or you trust the other users not to delete your photos from your camera :p.
3 JohnMcPherson 60
61 ''Note - you probably don't need to do this manually any more... most distributions probably do this for you. Eg Debian Sarge and Sid, and Ubuntu now (libgphoto2-2 ver 2.1.4-8, Nov 2004) have a script that lets people in the 'camera' group access the device'' -- JohnMcPherson
1 JohnMcPherson 62
63 usb/usbcam:
4 JohnMcPherson 64 <verbatim>
1 JohnMcPherson 65 #!/bin/sh
66 # John - we need to make the usb device readable/writeable by normal
67 # users. Should be the same person as on console, but debian doesn't
68 # change /dev/console to the current user, so make it world +rw.
69 chmod a+rw "$DEVICE"
4 JohnMcPherson 70 </verbatim>
1 JohnMcPherson 71
72 I'm not entirely sure that this really needs to be done every time, but I have noticed that sometimes [CUPS] can't talk to the printer if it is powered on after boot. Also see [CUPSNotes] to see where this command line came from.
73
74 usb/brother_hl1440:
4 JohnMcPherson 75 <verbatim>
1 JohnMcPherson 76 #!/bin/sh
77 foomatic-configure -s cups -n Brother -c file:/dev/usb/lp0 -p Brother-HL-1440 \
5 JohnMcPherson 78 -d hl1250 -o PageSize=A4
4 JohnMcPherson 79 </verbatim>
80
81 ----
82 ! Disabling the touchpad when a USB mouse is added
83 __1.__ I re-compiled the kernel so that PS/2 mouse support (psmouse.ko) is a module rather than compiled in.%%%
84 __2.__ Get [UDev] to create a symlink for the PS/2 touchpad. Eg: Create /etc/udev/rules.d/mouse.rules:
85 <verbatim>
86 BUS="usb", KERNEL="mouse[0-1]", NAME="input/%k" SYMLINK="input/usbmouse"
87 # for psmouse (synaptic touchpad)
88 KERNEL="mouse[0-1]" NAME="input/%k" SYMLINK="input/touchpad"
89 </verbatim>
90 __3.__ get Xfree/Xorg to use /dev/input/mice as the core pointer, of type IMPS/2. All mice on the system send events via /dev/input/mice as well as each individual /dev/input/mouse<n> device. Add a secondary mouse that points to /dev/input/touchpad.%%%
91 __4.__ Set up a hotplug script that disables the touchpad when a usb mouse is added. __Note!__ I had to comment out "usbmouse" from /etc/hotplug/blacklist otherwise hotplug ignores usb mouse events!
92 /etc/hotplug/usb/usbmouse.usermap:
93 <verbatim>
94 # el cheapo optical usb scroll mouse:
95 usbmouse 0x03 0x09da 0x0006 0 0 0 0 0 0 0 0 0
96 </verbatim>
97
98 /etc/hotplug/usb/usbmouse:
99 <verbatim>
100 #!/bin/sh
101
102 # this removes the psmouse.ko kernel module for the touchpad when a
103 # usb mouse is plugged in, and re-inserts the module when the usb mouse
104 #is removed.
105
106 if test "$ACTION" = "add" ; then
107 rmmod psmouse
108 if test -n "$REMOVER" ; then
109 # usb.agent sets this variable to point to an executable that
110 # will be run on remove, if it exists
111 ln -s "$0" "$REMOVER"
112 fi
113 elif test "$ACTION" = "remove" ; then
114 modprobe psmouse
115 # else unknown action?
116 fi
117
118 </verbatim>
6 MattBoyd 119 I'm using kernel 2.6.12 and the module name is usbhid not usbmouse. I had the touchpad working already so all I needed to do was, comment out usbmouse from /etc/hotplug/blacklist and add the above script as /etc/hotplug/usb/usbhid then do a chmod +x /etc/hotplug/usb/usbhid.
1 JohnMcPherson 120
121 !!![PCMCIA]/CardBus
122 By default, HotPlug in Debian (testing/unstable at least as of July 2004) won't automatically configure network interfaces.
123
10 AndreaBorgia 124 In /etc/default/hotplug, there is a variable named NET_AGENT_POLICY (obsolete as of Aug 5, 2005) that can be set to "all", "auto", or "hotplug", with hotplug being the
1 JohnMcPherson 125 default. This refers to which entries in /etc/network/interfaces should
126 be handled by hotplug.
127
128 My laptop's /etc/network/interfaces file includes the following lines:
4 JohnMcPherson 129 <verbatim>
1 JohnMcPherson 130 # use DHCP for the pccard network card
131 iface eth0 inet dhcp
132 # for the hotplug package
133 mapping hotplug
134 script echo
135 map eth0
9 PhilippeNael 136 </verbatim>
137
138 I use the hotplug package to configure automaticaly my WLAN card with
139 the following entries (It's an USR 5411 so I use the ndsiwrapper driver) :
140 <verbatim>
141 mapping hotplug
142 iface wlan0 inet dhcp
11 AndreaBorgia 143 pre-up wpa_supplicant -B -Dndiswrapper -iwlan0 -c/etc/wpa_supplicant.conf
9 PhilippeNael 144 pre-down killall wpa_supplicant
145
4 JohnMcPherson 146 </verbatim>