-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.sh
executable file
·72 lines (58 loc) · 1.42 KB
/
demo.sh
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
#!/bin/bash
GAME="$1"
DEMO=0
BASENAME=$(basename $0)
if [ "$BASENAME" = "demo.sh" ]
then
DEMO=1
fi
if [ "$GAME" = "random" ]
then
ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | wc -l)
LINE=$(( RANDOM % ITEMS + 1))
else
ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort -f | grep -i "$GAME" | wc -l)
if (( ITEMS == 0 ))
then
echo "game $GAME not found" >&2
exit 1
fi
curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort -f | grep -i "$GAME" | nl -nln
ITEM=1
if (( ITEMS > 1 ))
then
echo
echo -n "pick one: "
read ITEM
test -z "$ITEM" && ITEM=1
fi
LINE=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort -f | grep -ni "$GAME" | head -$ITEM | tail -1 | awk -F: '{print $1}')
fi
DOWN=$((LINE - 1))
TITLE=$(curl -sL http://asciiexpress.net/gameserver/links.html | sort -f | head -$LINE | tail -1 | awk -F\" '{print $4}')
echo
echo -n "${TITLE}..."
if ! OUTPUT=$(
osascript quick.scrp \
gameserverclient.dsk \
c_gameserverdisk_splash.tiff $((5 + DEMO * 10)) \
c_gameserverdisk_mainscreen.tiff $((5 + DEMO * 10)) \
$DOWN \
$DEMO
)
then
echo FAILED
exit 1
fi
if echo $OUTPUT | grep ERROR >/dev/null 2>&1
then
echo FAILED
echo $OUTPUT
echo
exit 1
fi
rm -f quick.aif
echo LAUNCHED
echo
#xdotool windowfocus $WINDOWID 2>/dev/null
#osascript -e 'activate application "XQuartz"'