3
# /etc/hotplug/usb/usbcam
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
9
# to debug this script, uncomment the next line and see /tmp/usbcam.debug after execution
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
17
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
19
chmod a-rwx "${DEVICE}"
20
chgrp "${GROUP}" "${DEVICE}"
21
chmod ug+rw "${DEVICE}"
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
30
echo "----" >> $DEBUGOUT
31
sh -x $0 $@ debug >> $DEBUGOUT 2>&1
35
# functions for syslog
36
LOGGER="logger -t `basename $0`[$$] -p user.notice"
41
if [ -z "$REMOVER" ]; then
42
write_syslog "No remover found"
46
dcop_users="`ps aux | grep dcopserver | grep -v grep | awk '{print $1}' | sort | uniq`"
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
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
58
write_syslog "Invoking dcop..."
59
write_syslog "kded mediamanager removableCamera $DEVICE \"$manufacturer $product\""
61
method="kded mediamanager removablePlug"
62
for user in $dcop_users ; do
63
dcop --user $user --all-sessions $method $DEVICE "$manufacturer $product"
66
method="kded mediamanager removableCamera"
67
for user in $dcop_users ; do
68
dcop --user $user --all-sessions $method $DEVICE
71
elif [ "$ACTION" = "remove" ]; then
72
write_syslog "Invoking dcop..."
73
write_syslog "kded mediamanager removableUnplug $DEVICE"
75
method="kded mediamanager removableUnplug"
76
for user in $dcop_users ; do
77
dcop --user $user --all-sessions $method $DEVICE