#!/bin/sh
#Barry Kauler, Oct. 2011
#called via udev /etc/udev/rules.d/88-puppy-autodetect.rules
#111007 first release.
#111010 maybe wait until delayedrun has done its stuff.

[ ! $1 ] && exit
[ "`pidof X`" == "" ] && exit #X not running.
export PATH='/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/root/my-applications/bin'
export DISPLAY=':0'

#111010 maybe wait until delayedrun has done its stuff...
EXCNT=0
while [ ! -f /tmp/delayedrun_finished_flag ];do #see /usr/sbin/delayedrun.
 sleep 2
 EXCNT=$(($EXCNT + 1))
 [ $EXCNT -gt 10 ] && break #precaution
done


case $1 in
 camera)
  pupcamera &
 ;;
 android-device)
  mtpdevice mount &
 ;;

esac
