From 933a93e4a71591e867182999a7daf8ae3bad5596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Fri, 15 Feb 2013 12:34:32 +0100 Subject: Major overhaul: Support non-wine games * Moved wine support to own template * Added xpad template * Added no-x template for games that don't support being started on another X. * Improved ways template functions work together: - EXPORT now appends - OVERRIDE replaces all the others - in game: command 'super' to call the phases of the templates - super supports "-r tpl" to remove the phase function of tpl --- templates/cdemu | 3 --- templates/default | 15 ++++++++++----- templates/fuseiso | 3 --- templates/iso | 9 ++++++++- templates/no-x | 12 ++++++++++++ templates/steam | 28 ++++++++++++++++++++++------ templates/wine | 18 ++++++++++++++++++ templates/xpad | 21 +++++++++++++++++++++ 8 files changed, 91 insertions(+), 18 deletions(-) create mode 100644 templates/no-x create mode 100644 templates/wine create mode 100644 templates/xpad (limited to 'templates') diff --git a/templates/cdemu b/templates/cdemu index f6690a8..f532106 100644 --- a/templates/cdemu +++ b/templates/cdemu @@ -4,8 +4,6 @@ _cdemu_dev () { } cdemu_prepare () { - default_prepare - declare -g MOUNT CDEMU_NO [[ $MOUNT != /* ]] && MOUNT="$HOME/isos/spiele/$MOUNT" @@ -16,7 +14,6 @@ cdemu_prepare () { } cdemu_cleanup () { - default_cleanup exc umount $(_cdemu_dev) exc cdemu unload $CDEMU_NO } diff --git a/templates/default b/templates/default index 2f62395..0d1c0ea 100644 --- a/templates/default +++ b/templates/default @@ -4,16 +4,21 @@ default_setupX () { play_setupX } +default_setenv () { + if loaded wine; then + EENV[WINEPREFIX]='{ [[ -z $NO_WINEINSTS ]] && echo $HOME/.wineinsts/$PREFIX; } || echo $PREFIX' + fi + + play_setenv +} + default_prepare () { - play_prepare } default_cleanup () { - play_cleanup } -EENV[WINEPREFIX]='{ [[ -z $NO_WINEINSTS ]] && echo $HOME/.wineinsts/$PREFIX; } || echo $PREFIX' - -EXPORT setupX prepare cleanup +EXPORT prepare cleanup +OVERRIDE setenv setupX # vim:ft=sh diff --git a/templates/fuseiso b/templates/fuseiso index 97df277..0be20ff 100644 --- a/templates/fuseiso +++ b/templates/fuseiso @@ -1,7 +1,5 @@ fuseiso_prepare () { - default_prepare - declare -g MOUNT MOUNTTARGET [[ $MOUNT != /* ]] && MOUNT="$HOME/isos/spiele/$MOUNT" @@ -10,7 +8,6 @@ fuseiso_prepare () { } fuseiso_cleanup () { - default_cleanup exc fusermount -u $MOUNTTARGET } diff --git a/templates/iso b/templates/iso index 2aad3cd..2b65c26 100644 --- a/templates/iso +++ b/templates/iso @@ -1,3 +1,6 @@ +# +# NB: MUST be included before other templates defining cleanup and prepare +# if [[ -z $ISO_TYPE ]]; then # default @@ -18,12 +21,16 @@ esac # wrapper phases iso_prepare () { + default_prepare ${ISO_TYPE}_prepare } iso_cleanup () { + default_cleanup ${ISO_TYPE}_cleanup } -EXPORT prepare cleanup +# we need to OVERRIDE and not EXPORT, to not execute them twice +# as they are already exported in the other template +OVERRIDE prepare cleanup # vim:ft=sh diff --git a/templates/no-x b/templates/no-x new file mode 100644 index 0000000..e811e85 --- /dev/null +++ b/templates/no-x @@ -0,0 +1,12 @@ +unset "ENV[DISPLAY]" + +no-x_startX () { + exc $BIN --in-X $GAME +} + +no-x_setupX () { +} + +OVERRIDE startX setupX + +# vim:ft=sh diff --git a/templates/steam b/templates/steam index 3321e92..2516277 100644 --- a/templates/steam +++ b/templates/steam @@ -1,9 +1,25 @@ -PREFIX="steam" -SIZE="1280x960" -GPATH="c:/program files/steam/steam.exe" +if loaded wine; then + PREFIX="steam" + #SIZE="1280x960" + GPATH="c:/program files/steam/steam.exe" -steamapp () { - [[ $# > 0 ]] && export ARGS="-applaunch ${=@}" -} + steamapp () { + [[ $# -gt 0 ]] && export ARGS="-applaunch ${=@}" + } +else + GPATH=steam + SIZE=1680x1050 + + steamapp () { + [[ $# -gt 0 ]] && export ARGS="steam://rungameid/$1" + } + + # force cleanup -- yields a normal shutdown + steam_cleanup () { + [[ $1 == force ]] && exc steam -shutdown + } + + OVERRIDE cleanup +fi # vim:ft=sh diff --git a/templates/wine b/templates/wine new file mode 100644 index 0000000..e6c8d2e --- /dev/null +++ b/templates/wine @@ -0,0 +1,18 @@ +EENV[WINEPREFIX]='eval echo $PREFIX' +PREFIX=${PREFIX:-$GAME} + +# run wine and therefore the game +wine_run () { + # cd into dir + local dir="$(exc winepath -u $GPATH)" + exc cd "${dir:h}" + + # start game + exc wine start ${dir:t} "$ARGS" + + # wait for wine to shutdown + exc wineserver -w +} + +OVERRIDE run +# vim: ft=sh diff --git a/templates/xpad b/templates/xpad new file mode 100644 index 0000000..1e67429 --- /dev/null +++ b/templates/xpad @@ -0,0 +1,21 @@ +xpad_prepare () { + declare -g XBOX_PID XBOX_DEADZONE XBOX_UIAXISMAP \ + XBOX_UIBUTTONMAP XBOX_NO_FF + + local args="--silent \ + --deadzone ${XBOX_DEADZONE:-4000}" + + [[ -n $XBOX_UIAXISMAP ]] && args+=" --ui-axismap $XBOX_UIAXISMAP" + [[ -n $XBOX_UIBUTTONMAP ]] && args+=" --ui-buttonmap $XBOX_UIBUTTONMAP" + [[ -z $XBOX_NO_FF ]] || args+=" --force-feedback" + + exc -b xboxdrv ${=args} + XBOX_PID=$! +} + +xpad_cleanup () { + [[ -n $XBOX_PID ]] && exc kill -SIGINT $XBOX_PID +} + +EXPORT prepare cleanup +# vim:ft=sh -- cgit v1.2.3