#!/bin/sh
#
# autoexec - this gets executed when the task applet is loaded by matchbox panel
#
PDAXCONF=$HOME/Choices/pdaxii13.conf
if [ -f $PDAXCONF ]; then
   PDAXII=true
else
   PDAXII=false
fi

# remove the splash screen
if [ "`pidof feh`" != "" ]; then
   killall feh 2>/dev/null
fi

if [ "$PDAXII" = "true" ]; then

# start torsmo
  if [ "`which torsmo`" != "" ]; then
    if [ "`grep TORSMO $PDAXCONF|grep true`" != "" ]; then
        torsmo -d &
    fi
  fi

# start glipper
  if [ "`which glipper`" != "" ]; then
    if [ "`grep GLIPPER $PDAXCONF|grep true`" != "" ]; then
	if [ "`pidof glipper`" = "" ]; then
          glipper &
        fi
    fi
  fi

# bluetooth
  if [ "`which gnome-obex-server`" != "" ] || [ "`which gnome-phone-manager`" != "" ]; then
    CID=`cardctl ident 0|head -1`
    if [ "`echo $CID|grep 'no product info available'`" = "" ]; then
      BID=`echo $CID|cut -d, -f2-|cut -d\" -f2-|tr -d \"`
      BTT=`grep "$BID" /etc/pcmcia/bluetooth.conf`
      if [ "$BTT" != "" ]; then
        if [ "`grep BLUETOOTH_DAEMON $PDAXCONF|grep true`" != "" ]; then
	  if [ "`pidof gnome-obex-server`" = "" ]; then
            gnome-obex-server &
          fi
        fi
        if [ "`grep BLUETOOTH_MANAGER $PDAXCONF|grep true`" != "" ]; then
	  if [ "`pidof gnome-phone-manager`" = "" ]; then
            gnome-phone-manager &
          fi
        fi
      fi
    fi
  fi

fi

# multi-panel
#if [ "`ps -ef|grep matchbox-panel|grep id`" = "" ]; then
#  sleep 15
#  multi-panel 1
#  sleep 15
#  multi-panel 2
#  sleep 15
#  multi-panel 3
#  sleep 15
#  wmctrl -s 0
#fi
if [ "`pidof icewm`" != "" ]; then
  sleep 15 
  wmctrl -a ROX-Filer
  killall mb-applet-tasks
fi

exit 0
