#!/bin/sh
#========

echo -n '(!) vrx Virtual Resource load / eXec v1.20 for SliTaz : ['$1'] '
date +%G%b%d%a.%P%H:%M:%S

# single point executable registry for disk resident software extensions
# cxr is Compressed eXecutable Resources (knoppix style cloop)
# called from IceWM menu, MC bindings & menu, scripts, commandline

KPROG=$1
KEXEC=$2

case "${KPROG}" in

"java"       ) set /opt/java16     java16.cxr     norun   ;;
"nvision"    ) set /opt/java16     java16.cxr     nvj20/runnviz ;;
"microemu"   ) set /opt/java16     java16.cxr     me204/runmemu ;;
"xine"       ) set /usr/share      nocxr.cxr      runxine ;;
"wine"       ) set /opt/winedeps   winedeps.cxr   runwine ;;
"dosbox"     ) set /opt/dossoft    dossoft.cxr    rundos  ;;
"gnudev"     ) set /opt/gnudev     gnudev.cxr     gnudev  ;;
"mplayer"    ) set /opt/mplayer    mplayer.cxr    runmp   ;;
"celestia"   ) set /opt/celestia   celestia.cxr   runcele ;;
"stellarium" ) set /opt/stellarium stellarium.cxr runstel ;;
"wmmoonc"    ) set /opt/wmmoonc    wmmoonc.cxr    wmmoonc ;;
"xfishtank"  ) set /opt/xfishtank  xfishtank.cxr  bin/runxftk ;;
"astrolog"   ) set /opt/astrolog   astrolog.cxr   runalog ;;
"xsky"       ) set /opt/xsky       xsky.cxr       xsky-4.0/exec/xsky40 ;;

*) echo $0 : undefined argument ; exit 1
;;
esac ;             OPTDIR=$1     ; VRLOAD=$2    ; IWEXEC=$3

# install cxr (to /opt) if uninstalled
[ -d ${OPTDIR} ] || $(zkp)/sh/shcloop ${HOME}/.config/vrxpath/cxr/${VRLOAD}

# validate install only
[ "${KEXEC}" == "--norun" ] && exit 0

# programs run in xterms or from scripts
KXT="echo xterm -name ${KPROG} -title ${VRLOAD} -e ${OPTDIR}"

 case "${KPROG}" in
#  "mc"         ) OPTDIR=$(${KXT}) ;;
#  "vfu"        ) OPTDIR=$(${KXT}) ;;
#  "nchex"      ) OPTDIR=$(${KXT}) ;;
#  "procps"     ) OPTDIR=$(${KXT}) ;;
#  "dselect"    ) OPTDIR=$(${KXT}) ;;
#  "superuser"  ) OPTDIR=$(${KXT}) ;;
#  "freebsd"    ) OPTDIR=$(${KXT}) ;;
#  "irssi"      ) OPTDIR=$(${KXT}) ;;
#  "nftp"       ) OPTDIR=$(${KXT}) ;;
   "xine"       ) OPTDIR=$(zkp)/sh ;;
   "wine"       ) OPTDIR=$(zkp)/sh ;;
   "dosbox"     ) OPTDIR=$(zkp)/sh ;;
   "gnudev"     ) OPTDIR=$(zkp)/sh ;;
   "mplayer"    ) OPTDIR=$(zkp)/sh ;;
   "celestia"   ) OPTDIR=$(zkp)/sh ;;
   "stellarium" ) OPTDIR=$(zkp)/sh ;;
   "nvision"    ) OPTDIR=${HOME}/.config/vrxpath/jar ;;
   "microemu"   ) OPTDIR=${HOME}/.config/vrxpath/jar ;;
 esac

# thats all folkz (!)

# echo ${OPTDIR}/${IWEXEC}
       ${OPTDIR}/${IWEXEC} ${KEXEC} &

exit 0