Code:
#!/bin/bash
#
# startcs
# version 1.0
#
# with this script you can start every hl/hl2/source game you want steam or steamless
# you can set custom server, command line options, custom steam or hl1 games, screen resolution
#
# set wine: use a virtual desktop
#
# games: cs16 cs15 cs:s dod dod:s hl2 tf2
#
# usage: startcs cs15 [ip:port]
#
#####################################################################################
# SETTINGS
#####################################################################################
# set a custom application for steam
# e.g. custom string AP1=cs16 application number NR1=10
AP1=""
NR1=""
# set a custom application for steamless half-life
# e.g. custom string AP2=cs15 application name NR2=cstrike
AP2=""
NR2=""
# set mouseacc ON or OFF
MOUSEACC=OFF
# set heapsize
MEM=393216
# set screen-resolution for cs
SIZE=800x600
#set fullscreen YES, NO
FULL=YES
# set dxlevel [70|80|90|95]
DIRECTX=95
# set all custom startparameter
OTHER="-noaafonts -console -ipx"
# set gamedir steam or half-life
HLDIR=$HOME/.wine/drive_c/Half-Life
STEAMDIR=$HOME/.wine/drive_c/steam
# set configfile for nvidia-settings default ~/.nvidia-settings-rc or let it free
NVDIR="$HOME/cstrike/nvidia-settings.rc"
# set your favorite servers here: ./script cs1.6 serverxxx
SIP1="88.80.202.213:15000"; SNAME1=cs15server
SIP2="83.142.80.79:27040" ; SNAME2=cs16server
SIP3="83.142.80.80:27040" ; SNAME3=sccserver
SIP4= ; SNAME4=
#####################################################################################
# SCRIPT
#####################################################################################
GAMEDIR=$STEAMDIR
APP=-applaunch
GAMEEXE=steam.exe
# check game
if [ -n "$1" ]; then
case $1 in
cs16) APPLICATION="10";;
css) APPLICATION="240";;
hl2) APPLICATION="220";;
dods) APPLICATION="300";;
dod) APPLICATION="30";;
cz) APPLICATION="80";;
tf2) APPLICATION="440";;
cs15) APPLICATION=cstrike; GAMEDIR=$HLDIR; APP="-game"; GAMEEXE=hl.exe;;
$AP1) APPLICATION="$NR1";;
$AP2) APPLICATION="$NR2"; GAMEDIR=$HLDIR; APP="-game"; GAMEEXE=hl.exe;;
-h|--help) echo " ";
echo "options are [cs16|css|hl2|dods|dod|cz|tf2|cs15]";
echo "example: starcs cs16 [ip:port]";
echo " ";
exit;;
*) echo "try --help"; exit;;
esac
else
echo "try --help"; exit
fi
# grep current screen-resolution
RANDR=`xrandr -q | awk -F"[ ,]" '/current/{print $9"x"$11}'`
# set mouse acc ON or OFF
if [ $MOUSEACC == OFF ]; then
ACC="-noforcemspd -noforcemaccel -noforcemparms"
XACC="xset m 0 0"
fi
# set screen-resolution
for S in $SIZE; do
case $S in
640x480) CSSIZE="-w 640 -h 480";;
800x600) CSSIZE="-w 800 -h 600";;
1024x768) CSSIZE="-w 1024 -h 768";;
1152x864) CSSIZE="-w 1152 -h 864";;
1280x960) CSSIZE="-w 1280 -h 960";;
1280x1024) CSSIZE="-w 1280 -h 1024";;
1600x1024) CSSIZE="-w 1600 -h 1024";;
esac
done
# connect to server
if [ -n "$2" ]; then
case $2 in
$SNAME1) SE=$SIP1;;
$SNAME2) SE=$SIP2;;
$SNAME3) SE=$SIP3;;
$SNAME3) SE=$SIP4;;
*) SE=$2;;
esac
connect="+connect $SE"
else
connect=" "
fi
setnv() {
nvidia-settings -l --config=$NVDIR 2> /dev/null
}
startcs() {
$RANDR &>/dev/null
# set fullscreen ON or OFF
if [ $FULL == YES ]; then
xrandr -s $SIZE
fi
setnv
# start game
cd $GAMEDIR
WINEDEBUG=-all wine $GAMEEXE $APP $APPLICATION $CSSIZE \
-dxlevel $DIRECTX -heapsize $MEM $ACC $OTHER $connect
}
stopcs() {
cd -
nvidia-settings -l --config="~/.nvidia-settings-rc"
xrandr -s $RANDR
}
if [ -d $GAMEDIR ]; then
startcs
else
echo "gamedir is not valid"; exit
fi
stopcs
exit 0