yet another launcher script

howdy,

I’m tired of the clickToRunScripts when running multiple of apps from the command line, so I made a generic script to launch the app and load the lib dir based on the dir path given. If you make it executable and throw it in you /usr/bin dir, then it makes things quicker, at least for me.

Try it out for me.

  
  
#!/bin/bash  
  
#	generic script to launch openframeworks apps in linux  
#	automatically loads lib dir  
#	2008 Dan Wilcox  
  
#### Variables/Definitions  
  
APP=""  
DIR=""  
  
HELP="Usage: oflauncher [options] /path/to/application  
  
 Starts an openframeworks app in the given dir,   
 automatically adds the lib path  
  
 -h, --help		This usage guide  
 -l, -libdir	Specify the lib directory  
"  
  
#### BEGIN commandline parsing  
  
# We need TEMP as the `eval set --' would nuke the return value of getopt.  
TEMP=`getopt -o c:l:h:: --long config: --long libdir: --long help:: \  
	  -n "oflauncher" -- "$@"`  
  
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi  
  
# Note the quotes around `$TEMP': they are essential!  
eval set -- "$TEMP"  
  
while true ; do  
	case "$1" in  
		-h|--help)	# print help and exit  
			echo "$HELP"; exit 0 ;;  
		-l|--libdir)	# grab library dir  
			case "$2" in  
				*)  DIR=$2 ;  shift 2 ;;  
			esac ;;  
		--) shift ; break ;;	# do nothing  
		*) break ;;  
	esac  
done  
  
# get program name from commandline  
if [ "$1" != "" ] ; then  
	APP=$1  
fi  
  
# if program name dosent exist, exit  
if [ ! -e $APP ] ; then  
	echo "oflauncher: '$(basename $APP)' does not exist, exiting"  
	exit 0  
fi  
  
# set lib dir, if not specified  
if [ "$DIR" = "" ] ; then  
	DIR=$(dirname $APP)/libs/  
fi  
  
#### Begin execution  
  
echo "oflauncher: cd to '$(dirname $APP)'"  
cd $(dirname $APP)  
  
echo "oflauncher: adding lib path: '$DIR'"  
# add lib path  
export LD_LIBRARY_PATH=$DIR  
  
echo "oflauncher: running $(basename $APP)"  
# run app  
./$(basename $APP)  
  
echo "oflauncher: done"