summaryrefslogtreecommitdiff
path: root/play.sh
blob: 3c8a4ede82a53526ba5c89ff108512abcab59c2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/zsh

exp () {
    echo "*** Setting envvar '$1' to '$2'"
    export $1=$2
}

exc () {
    if [[ $1 == "-f" ]]; then
        fork=1
        msg=" (forking)"
        shift
    fi

    echo "*** Executing${msg}:"
    echo $@
    
    sleep 3

    if [[ -n $fork ]]; then
        exec $@ &!
    else
        eval $@
    fi
}

if [[ $1 == "-x" ]]; then
    local prefix=$2
    local gpath=$3
    local args=$5
    local size=$4

    # load settings
    nvidia-settings -l

    # set display size
    [[ -n $size ]] && xrandr -s $size

    # exporting variables
    exp WINEPREFIX `eval echo $prefix`
    exp WINEDEBUG "-all"
    exp DISPLAY ":1"

    exc wine start $gpath $args
    exc wineserver -w
else
    local game=$1

    echo "*** Launching '$game'"

    local prefix="~/.wine/"
    local gpath size args
    local x11args

    steam () {
        prefix="~/.steam/"
        gpath="c:/Programme/steam/steam.exe"
        size="1280x1024"

        [[ $# > 0 ]] && args=$@
    }

    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'

    if [[ -z $games[$game] ]]; then
        echo "*** Game '$game' not found"
        echo "Games are:"
        for k in ${(ko)games}; do
            echo "\t> $k"
        done
        exit 1
    else
        eval $games[$game]
    fi

    exc -f startx $0 -x $prefix $gpath $size "$args" -- :1 -ac -br -quiet ${=x11args}
fi