~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

Viewing changes to kioslave/media/contrib/usbcam

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-27 12:09:48 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20080527120948-dottsyd5rcwhzd36
Tags: 4:4.0.80-1ubuntu1
* Merge with Debian
 - remove 97_fix_target_link_libraries.diff
 - Add replaces/conflicts on -kde4 packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
#
3
 
# /etc/hotplug/usb/usbcam
4
 
#
5
 
# Set up newly plugged in USB camera
6
 
# Notify all KDE sessions (thanks to the mediamanager) that a
7
 
# new camera appeared or disappeared
8
 
 
9
 
# to debug this script, uncomment the next line and see /tmp/usbcam.debug after execution
10
 
#DEBUG=1
11
 
 
12
 
# exit immediately if /usr/bin/ is not yet available (during boot if /usr is a separate partition)
13
 
/bin/ls -d /usr/bin/ >/dev/null 2>&1 || exit
14
 
 
15
 
GROUP=camera
16
 
 
17
 
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
18
 
then
19
 
    chmod a-rwx "${DEVICE}"
20
 
    chgrp "${GROUP}" "${DEVICE}"
21
 
    chmod ug+rw "${DEVICE}"
22
 
fi
23
 
 
24
 
 
25
 
DEBUGOUT=/tmp/usbcam.debug.$$
26
 
if [ "$DEBUG" = "1" -a -z "$2" ]; then
27
 
  echo "executing $0 $@" > $DEBUGOUT
28
 
  echo "with the following environment variables:" >> $DEBUGOUT
29
 
  env >> $DEBUGOUT
30
 
  echo "----" >> $DEBUGOUT
31
 
  sh -x $0 $@ debug >> $DEBUGOUT 2>&1
32
 
  exit
33
 
fi
34
 
 
35
 
# functions for syslog
36
 
LOGGER="logger -t `basename $0`[$$] -p user.notice"
37
 
write_syslog () {
38
 
  echo ${@} | $LOGGER
39
 
}
40
 
 
41
 
if [ -z "$REMOVER" ]; then
42
 
  write_syslog "No remover found"
43
 
  exit
44
 
fi
45
 
 
46
 
dcop_users="`ps aux | grep dcopserver | grep -v grep | awk '{print $1}' | sort | uniq`"
47
 
 
48
 
# if the current device is being added
49
 
if [ "$ACTION" = "add" ]; then
50
 
  write_syslog "Copying remover..."
51
 
  cp /etc/hotplug/usb/usbcam $REMOVER
52
 
  chmod +x $REMOVER
53
 
  # get camera information
54
 
  camera="/sys${DEVPATH}/.."
55
 
  if [ -e $camera/product ]; then product="`cat $camera/product`"; fi
56
 
  if [ -e $camera/manufacturer ]; then manufacturer="`cat $camera/manufacturer`"; fi
57
 
 
58
 
  write_syslog "Invoking dcop..."
59
 
  write_syslog "kded mediamanager removableCamera $DEVICE \"$manufacturer $product\""
60
 
 
61
 
  method="kded mediamanager removablePlug"
62
 
  for user in $dcop_users ; do
63
 
    dcop --user $user --all-sessions $method $DEVICE "$manufacturer $product"
64
 
  done
65
 
  
66
 
  method="kded mediamanager removableCamera"
67
 
  for user in $dcop_users ; do
68
 
    dcop --user $user --all-sessions $method $DEVICE
69
 
  done
70
 
  
71
 
elif [ "$ACTION" = "remove" ]; then
72
 
  write_syslog "Invoking dcop..."
73
 
  write_syslog "kded mediamanager removableUnplug $DEVICE"
74
 
 
75
 
  method="kded mediamanager removableUnplug"
76
 
  for user in $dcop_users ; do
77
 
    dcop --user $user --all-sessions $method $DEVICE
78
 
  done
79
 
  
80
 
fi
81
 
 
82