#!/bin/sh
#------------------------------------------------------------
# ETQW Linux Demoviewer 0.1
# written by WoH|Bene
# http://mywoh.de
# quakenet #woh

# dont forget to create a demos directory in your ETQW profile\base dir

#---------------------------------
# edit paths to yours
----------------------------------
# define path to demoviewer script
scriptpath=/home/bene/demoviewer

# define your ETQW installation
ETQW=/home/bene/ETQW

# define your ETQW profile path
ETQW_PROFILE=/home/bene/.etqwcl

# define your ETQW profile\sdnet\username\base path
ETQW_SDNET=/home/bene/.etqwcl/sdnet/bene/base
#---------------------------
# edit end
#---------------------------


# dummy demowatcher.ndm path
copy_path=$ETQW_PROFILE/base/demos/demowatcher.ndm
# path to copy demo.cfg
democfg_copy_path=$ETQW_PROFILE/base/demo.cfg
# copy demo.cfg to profile folder
cp -f $scriptpath/demo.cfg $democfg_copy_path

# define paths to etqwbinds.cfg and sdnet\username\bindings.cfg
backup_config=$ETQW_PROFILE/base/etqwbinds.cfg
backup_path=$ETQW_PROFILE/base/etqwbinds.cfg.backup
sdnet_file=$ETQW_SDNET/bindings.cfg
sdnet_backup=$ETQW_SDNET/bindings.cfg.backup

# copy etqwbinds.cfg to etqwbinds.cfg.backup
cp -f $backup_config $backup_path

# copy sdnet\user\bindings.cfg to sdnet\user\bindings.cfg.backup
cp -f $sdnet_file $sdnet_backup

# copy doubleclicked file to demos dir
cp -f $1 $copy_path

# fix for ^ key to open console (if you have problems with console on ^ , make # before the two xmodmap commands
xmodmap -e "keycode 49 = quoteleft asciitilde"
# start etqw
cd $ETQW && ./etqw.x86 "$@" +set fs_homepath "$ETQW" +set fs_basepath "$ETQW" +playNetDemo demowatcher.ndm +exec demo.cfg
xmodmap -e "keycode 49 = asciicircum degree notsign notsign notsign"

# copy backupped files to original ones
cp -f $sdnet_backup $sdnet_file
cp -f $backup_path $backup_config

# delete some generated files
rm $sdnet_backup
rm $backup_path
rm $democfg_copy_path
rm $copy_path
