summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-06-15 01:53:30 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-06-15 01:53:30 +0200
commit9786e03de9c14445769c4d04130f6512f16fbb9d (patch)
tree3a1db0bdbfa2a15fa0fa4ab971cbd4bf63604006
parent2b51b03b6284a0a8c8a1f4f73db152dc577b626d (diff)
downloadplay-9786e03de9c14445769c4d04130f6512f16fbb9d.tar.gz
play-9786e03de9c14445769c4d04130f6512f16fbb9d.tar.bz2
play-9786e03de9c14445769c4d04130f6512f16fbb9d.zip
Moved to the ebuild-like way
-rw-r--r--default39
-rw-r--r--games/bg22
-rw-r--r--games/fallout3
-rw-r--r--games/steam7
-rw-r--r--games/torchlight3
-rwxr-xr-xplay.sh86
6 files changed, 90 insertions, 50 deletions
diff --git a/default b/default
new file mode 100644
index 0000000..29f24c0
--- /dev/null
+++ b/default
@@ -0,0 +1,39 @@
+# exporting variables
+EENV[WINEPREFIX]='eval echo $PREFIX'
+ENV[WINEDEBUG]="-all"
+ENV[DISPLAY]=":1"
+
+PREFIX="~/.wine"
+
+default_execute () {
+ exc -f startx $BIN -x $GAME -- :1 -ac -br -quiet ${=EXARGS}
+}
+
+default_prepare () {
+ nvidia-settings -l
+
+ # set display size
+ [[ -n $SIZE ]] && xrandr -s $SIZE
+}
+
+default_setenv () {
+ for e v in ${(kv)ENV}; do
+ exp $e $v
+ done
+
+ for e v in ${(kv)EENV}; do
+ exp $e `eval $v`
+ done
+}
+
+default_run () {
+ # start game
+ exc wine start $GPATH "$ARGS"
+
+ # wait for wine to shutdown
+ exc wineserver -w
+}
+
+EXPORT default execute prepare setenv run
+
+# vim:ft=zsh
diff --git a/games/bg2 b/games/bg2
new file mode 100644
index 0000000..bb581ba
--- /dev/null
+++ b/games/bg2
@@ -0,0 +1,2 @@
+SIZE="1024x768"
+GPATH="c:/spiele/bg2/baldur.exe"
diff --git a/games/fallout b/games/fallout
new file mode 100644
index 0000000..3aac10a
--- /dev/null
+++ b/games/fallout
@@ -0,0 +1,3 @@
+PREFIX="~/.fallout"
+SIZE="640x480"
+GPATH="c:/spiele/fallout/falloutw.exe"
diff --git a/games/steam b/games/steam
new file mode 100644
index 0000000..1014061
--- /dev/null
+++ b/games/steam
@@ -0,0 +1,7 @@
+PREFIX="~/.steam"
+SIZE="1280x1024"
+GPATH="c:/programme/steam/steam.exe"
+
+steamapp () {
+ [[ $# > 0 ]] && export ARGS="-applaunch ${=@}"
+}
diff --git a/games/torchlight b/games/torchlight
new file mode 100644
index 0000000..cf050f1
--- /dev/null
+++ b/games/torchlight
@@ -0,0 +1,3 @@
+inherit steam
+
+steamapp 41600
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