From 9786e03de9c14445769c4d04130f6512f16fbb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Tue, 15 Jun 2010 01:53:30 +0200 Subject: Moved to the ebuild-like way --- play.sh | 86 +++++++++++++++++++++++++++-------------------------------------- 1 file changed, 36 insertions(+), 50 deletions(-) (limited to 'play.sh') diff --git a/play.sh b/play.sh index 973669a..92934e5 100755 --- a/play.sh +++ b/play.sh @@ -1,7 +1,11 @@ -#!/bin/zsh +#!/bin/zsh -f + +log () { + echo "*** $@" +} exp () { - echo "*** Setting envvar '$1' to '$2'" + log "Setting envvar '$1' to '$2'" export $1=$2 } @@ -12,7 +16,7 @@ exc () { shift fi - echo "*** Executing${msg}:" + log "Executing${msg}:" echo $@ sleep 3 @@ -24,64 +28,46 @@ exc () { fi } -if [[ $1 == "-x" ]]; then - local prefix=$2 - local gpath=$3 - local args=$5 - local size=$4 +EXPORT () { + local name=$1 + shift - # load settings - nvidia-settings -l + for f in $@; do + eval "$f () { ${name}_${f}; }" + done +} - # set display size - [[ -n $size ]] && xrandr -s $size +inherit () { + source games/$1 +} - # exporting variables - exp WINEPREFIX `eval echo $prefix` - exp WINEDEBUG "-all" - exp DISPLAY ":1" +typeset -A ENV EENV +BIN=$0 - # start game - exc wine start $gpath "$args" - - # wait for wine to shutdown - exc wineserver -w +source default - # when the script reaches this point, - # the new X will be terminated +if [[ $1 == "-x" ]]; then + source games/$2 + setenv + prepare + run else - local game=$1 - - echo "*** Launching '$game'" + GAME=$1 - local prefix="~/.wine/" - local gpath size args - local x11args - - steam () { - prefix="~/.steam/" - gpath="c:/Programme/steam/steam.exe" - size="1280x1024" - - [[ $# > 0 ]] && args="-applaunch ${=@}" - } - - typeset -A games - games[bg2]='gpath=c:/spiele/bg2/baldur.exe; size=1024x768' - games[fallout]='prefix=~/.fallout/; gpath=c:/spiele/fallout/falloutw.exe; size=800x600; x11args="-depth 16"' - games[steam]='steam' - games[torchlight]='steam 41600' - - if [[ -z $games[$game] ]]; then - echo "*** Game '$game' not found" + list () { echo "Games are:" - for k in ${(ko)games}; do + for k in games/*(.:t); do echo "\t> $k" done + } + + if [[ -z $GAME || ! -e games/$GAME ]]; then + [[ ! -e games/$GAME ]] && log "Game '$GAME' not found" + list exit 1 else - eval $games[$game] + log "Launching '$GAME'" + source games/$GAME + execute fi - - exc -f startx $0 -x $prefix $gpath $size $args -- :1 -ac -br -quiet ${=x11args} fi -- cgit v1.2.3