summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-06-15 02:58:13 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-06-15 02:58:13 +0200
commit4cfcbd3f435f114b8d29f1bf6d50a0378dd7c028 (patch)
tree92f5e27748cbe167707d8eb98c5cfd78c97c21c8
parent9786e03de9c14445769c4d04130f6512f16fbb9d (diff)
downloadplay-4cfcbd3f435f114b8d29f1bf6d50a0378dd7c028.tar.gz
play-4cfcbd3f435f114b8d29f1bf6d50a0378dd7c028.tar.bz2
play-4cfcbd3f435f114b8d29f1bf6d50a0378dd7c028.zip
added some games; added templates; added debug; moved functions to functions.sh
-rw-r--r--functions.sh43
-rw-r--r--games/bg22
-rw-r--r--games/fallout2
-rw-r--r--games/osmos5
-rw-r--r--games/steam8
-rw-r--r--games/torchlight2
-rwxr-xr-xplay.sh62
-rw-r--r--templates/default (renamed from default)4
-rw-r--r--templates/steam9
9 files changed, 83 insertions, 54 deletions
diff --git a/functions.sh b/functions.sh
new file mode 100644
index 0000000..e943dca
--- /dev/null
+++ b/functions.sh
@@ -0,0 +1,43 @@
+out () {
+ echo ">>> $@"
+}
+
+log () {
+ [[ $PLAY_DEBUG > 0 ]] && echo "*** $@"
+}
+
+exp () {
+ log "Setting envvar '$1' to '$2'"
+ export $1=$2
+}
+
+exc () {
+ cmd="eval"
+
+ if [[ $1 == "-e" ]]; then
+ cmd="exec"
+ shift
+ fi
+
+ if [[ $PLAY_DEBUG > 0 ]]; then
+ log "Executing (using '$cmd'):"
+ log "> $@"
+
+ sleep 3
+ fi
+
+ $cmd "$@"
+}
+
+EXPORT () {
+ local name=$1
+ shift
+
+ for f in $@; do
+ eval "$f () { ${name}_${f}; }"
+ done
+}
+
+inherit () {
+ source $PLAY_TEMPLATES/$1
+}
diff --git a/games/bg2 b/games/bg2
index bb581ba..cd052b2 100644
--- a/games/bg2
+++ b/games/bg2
@@ -1,2 +1,4 @@
SIZE="1024x768"
GPATH="c:/spiele/bg2/baldur.exe"
+
+# vim:ft=sh
diff --git a/games/fallout b/games/fallout
index 3aac10a..faafacb 100644
--- a/games/fallout
+++ b/games/fallout
@@ -1,3 +1,5 @@
PREFIX="~/.fallout"
SIZE="640x480"
GPATH="c:/spiele/fallout/falloutw.exe"
+
+# vim:ft=sh
diff --git a/games/osmos b/games/osmos
new file mode 100644
index 0000000..586acbc
--- /dev/null
+++ b/games/osmos
@@ -0,0 +1,5 @@
+inherit steam
+
+steamapp 29200
+
+# vim:ft=sh
diff --git a/games/steam b/games/steam
index 1014061..0b71daf 100644
--- a/games/steam
+++ b/games/steam
@@ -1,7 +1,3 @@
-PREFIX="~/.steam"
-SIZE="1280x1024"
-GPATH="c:/programme/steam/steam.exe"
+inherit steam
-steamapp () {
- [[ $# > 0 ]] && export ARGS="-applaunch ${=@}"
-}
+# vim:ft=sh
diff --git a/games/torchlight b/games/torchlight
index cf050f1..acfc3bc 100644
--- a/games/torchlight
+++ b/games/torchlight
@@ -1,3 +1,5 @@
inherit steam
steamapp 41600
+
+# vim:ft=sh
diff --git a/play.sh b/play.sh
index 92934e5..5667e81 100755
--- a/play.sh
+++ b/play.sh
@@ -1,73 +1,43 @@
#!/bin/zsh -f
-log () {
- echo "*** $@"
-}
+PLAY_DEBUG=${PLAY_DEBUG:-0}
-exp () {
- log "Setting envvar '$1' to '$2'"
- export $1=$2
-}
+[[ $PLAY_DEBUG == 2 ]] && setopt xtrace
-exc () {
- if [[ $1 == "-f" ]]; then
- fork=1
- msg=" (forking)"
- shift
- fi
-
- log "Executing${msg}:"
- echo $@
-
- sleep 3
-
- if [[ -n $fork ]]; then
- exec "$@" &!
- else
- eval "$@"
- fi
-}
-
-EXPORT () {
- local name=$1
- shift
-
- for f in $@; do
- eval "$f () { ${name}_${f}; }"
- done
-}
-
-inherit () {
- source games/$1
-}
+PLAY_DIR="${PLAY_DIR:-${0:h}}"
+PLAY_GAMES="${PLAY_GAMES:-$PLAY_DIR/games}"
+PLAY_TEMPLATES="${PLAY_TEMPLATES:-$PLAY_DIR/templates}"
typeset -A ENV EENV
BIN=$0
-source default
+source $PLAY_DIR/functions.sh
+
+inherit default
if [[ $1 == "-x" ]]; then
- source games/$2
+ source $PLAY_GAMES/$2
setenv
prepare
run
else
GAME=$1
+ DGAME="$PLAY_GAMES/$GAME"
list () {
- echo "Games are:"
- for k in games/*(.:t); do
+ out "Games are:"
+ for k in $PLAY_GAMES/*(.:t); do
echo "\t> $k"
done
}
- if [[ -z $GAME || ! -e games/$GAME ]]; then
- [[ ! -e games/$GAME ]] && log "Game '$GAME' not found"
+ if [[ -z $GAME || ! -e $DGAME ]]; then
+ [[ ! -e $DGAME ]] && out "Game '$GAME' not found"
list
exit 1
else
- log "Launching '$GAME'"
- source games/$GAME
+ out "Launching '$GAME'"
+ source $DGAME
execute
fi
fi
diff --git a/default b/templates/default
index 29f24c0..4fd9c50 100644
--- a/default
+++ b/templates/default
@@ -6,7 +6,7 @@ ENV[DISPLAY]=":1"
PREFIX="~/.wine"
default_execute () {
- exc -f startx $BIN -x $GAME -- :1 -ac -br -quiet ${=EXARGS}
+ exc -e startx $BIN -x $GAME -- :1 -ac -br -quiet ${=EXARGS}
}
default_prepare () {
@@ -36,4 +36,4 @@ default_run () {
EXPORT default execute prepare setenv run
-# vim:ft=zsh
+# vim:ft=sh
diff --git a/templates/steam b/templates/steam
new file mode 100644
index 0000000..321f646
--- /dev/null
+++ b/templates/steam
@@ -0,0 +1,9 @@
+PREFIX="~/.steam"
+SIZE="1280x1024"
+GPATH="c:/programme/steam/steam.exe"
+
+steamapp () {
+ [[ $# > 0 ]] && export ARGS="-applaunch ${=@}"
+}
+
+# vim:ft=sh