#!/bin/bash
### BEGIN BOOT SCRIPT INFO
#Long-Name: VirtualT
### END BOOT SCRIPT INFO
### BEGIN BOOT SCRIPT INSTALLATION DEFAULTS
#Launch-Mode: gui-only
### END BOOT SCRIPT INSTALLATION DEFAULTS
#
#This script uses a standard run scriptlet called RUN_VIRTUALT.<system name>,
#which should end with a call to run_virtualt. Unlike most other run functions,
#run_virtualt doesn't pass any arguments to virtualt, but rather accepts the
#model ID number as its only argment, and this ID is inserted into the
#configuration file.
#
#This requires VirtualT to be built with a version of FLTK that's been patched
#to accept FLTK_CONFIG_HOME as an alternate configuration directory.

set -e

. bootscriptfunctions.sh

CONFIG_FILE="conf/virtualt./virtualt.prefs"

run_virtualt()
{
	if [ ! "$1" ]
	then
		echo "$0: must specify a model ID"
		exit 1
	fi

	sed "s/^Model:[0-9][0-9]*$/Model:$1/g" -i "$CONFIG_FILE"

	export FLTK_CONFIG_HOME=$PWD/conf
	exec virtualt
}

call_run_scriptlet virtualt
