#!/bin/bash -login # This program is used to request a USB device connection using usbwatch # When a USB device is connected, /usr/sbin/do-hotmnt checks to see if this program # is running. If so the device is assigned to the user who is running usbconnect. # If someone is already running usbconnect exit immediately # we can only handle one device request at a time -just like hotplug itself if [[ `pgrep -n Xusbconnect` != `pgrep -o Xusbconnect` ]] ; then echo "Request denied" exit 0 fi PRG_USER=`whoami` MESSAGER="xmessage" pkill -u $PRG_USER $MESSAGER 2> /dev/null $MESSAGER -buttons '' -timeout 10 "$USER - Insert device and wait" & # kill -2 -u $PRG_USER usbwatch 2> /dev/null MAX_COUNT=0 while [ "`tail -n 5 /var/log/usbwatch | grep READY`" = "" -a "$MAX_COUNT" -lt "5" ] ; do let MAX_COUNT="$MAX_COUNT + 1" sleep 2 done