#!/bin/sh
#
# simple script to make mgapp behave like avencode.
# sets up a small configuration file in /tmp that will be used
# as the -c argument to mgapp.
# currently the two other plugins required to run avencode are 
# libmgapp.so and mobiapp.
# script assumes you have mgapp in your path, but if you don't,
# and you use some other path to get to this script, it will asume
# that your lib is a peer to whatever path you provided.
#
BINDIR=`dirname $0`
echo $* |grep -sq '\-\-ldpath'
if [ $? -eq 0 ]
then
	export LD_LIBRARY_PATH=.:${BINDIR}/../lib:${BINDIR}/../lib/plugins
	args=`echo $* | sed -e 's/--ldpath//g'`
else
	args=$*
fi

export PATH=${PATH}:.:${BINDIR}
rm -f /tmp/avencode_*.cfg
T_CFG=/tmp/avencode_$$.cfg
trap "rm ${T_CFG} ; exit 0" SIGINT SIGKILL
echo "mobiapp.so mobiapp $args" >> ${T_CFG}
echo "ui_rgb.so ui_rgb $args" >> ${T_CFG}
mgapp -c ${T_CFG} &
