2 # $Id: usbcam.x11-app 9668 2006-12-18 16:31:44Z hun $
4 # /etc/hotplug/usb/usbcam
6 # Sets up newly plugged in USB camera so that just one certain user
10 # can access it from user space. (Replace root by the user you want
11 # to have access to the cameras.)
13 # It then runs the X11 application (gtkam is used as an example)
15 X11_APP=/usr/bin/gtkam
17 # on the X11 display (:0 should work on most single user workstations)
21 # in the directory (~$USER is just the user's home directory)
26 # Note that for this script to work, you'll need all of the following:
27 # a) a line in the file /etc/hotplug/usermap that corresponds to the
28 # camera you are using. You can get the correct lines for all cameras
29 # supported by libgphoto2 by running
30 # $ print-camera-list usb-usermap usbcam
31 # b) run your camera software as the user given above
32 # c) a Linux kernel supporting hotplug and usbdevfs
33 # d) the hotplug package (http://linux-hotplug.sourceforge.net/)
38 # In the usermap file, the first field "usb module" should be named
39 # "usbcam" like this script.
41 # Script written by Trevor Woerner but slightly adapted for inclusion
47 if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
49 chmod a-rwx "${DEVICE}"
50 chown "${USER}" "${DEVICE}"
51 chmod u+rw "${DEVICE}"
53 if [ "${USER}" != "root" ]
55 # we don't want to run this as root. definitely not.
58 "${SU}" "${USER}" -c "${ENV} DISPLAY=${DISPLAY} HOME=${usrhome} ${X11_APP}"