home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / libgphoto2-2 / linux-hotplug / usbcam.x11-app < prev   
Encoding:
Text File  |  2006-08-30  |  1.6 KB  |  60 lines

  1. #!/bin/bash
  2. # $Id: usbcam.x11-app 6905 2003-10-30 16:27:08Z hun $
  3. #
  4. # /etc/hotplug/usb/usbcam
  5. #
  6. # Sets up newly plugged in USB camera so that just one certain user
  7.  
  8. USER=root
  9.  
  10. # can access it from user space. (Replace root by the user you want
  11. # to have access to the cameras.)
  12.  
  13. # It then runs the X11 application (gtkam is used as an example)
  14.  
  15. X11_APP=/usr/bin/gtkam
  16.  
  17. # on the X11 display (:0 should work on most single user workstations)
  18.  
  19. DISPLAY=:0
  20.  
  21. # in the directory (~$USER is just the user's home directory)
  22.  
  23. DIRECTORY=~$USER
  24.  
  25. #
  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 "print-usb-usermap".
  30. # b) run your camera software as the user given above
  31. # c) a Linux kernel supporting hotplug and usbdevfs
  32. # d) the hotplug package (http://linux-hotplug.sourceforge.net/)
  33. # e) su
  34. # f) env
  35. # g) X11
  36. #
  37. # In the usermap file, the first field "usb module" should be named 
  38. # "usbcam" like this script.
  39. #
  40. # Script written by Trevor Woerner but slightly adapted for inclusion
  41. # into libgphoto2. 
  42.  
  43. SU=/bin/su
  44. ENV=/usr/bin/env
  45.  
  46. if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
  47. then
  48.     chmod a-rwx "${DEVICE}"
  49.     chown "${USER}" "${DEVICE}"
  50.     chmod u+rw "${DEVICE}"
  51.  
  52.     if [ "${USER}" != "root" ]
  53.     then
  54.     # we don't want to run this as root. definitely not.
  55.     cd "${DIRECTORY}"
  56.     usrhome=~${USER}
  57.     "${SU}" "${USER}" -c "${ENV} DISPLAY=${DISPLAY} HOME=${usrhome} ${X11_APP}"
  58.     fi
  59. fi
  60.