Added gamelaunch
authorTim Pope <code@tpope.net>
Tue, 20 Jul 2004 21:35:41 +0000 (21:35 +0000)
committerTim Pope <code@tpope.net>
Tue, 20 Jul 2004 21:35:41 +0000 (21:35 +0000)
bin/gamelaunch [new file with mode: 0755]

diff --git a/bin/gamelaunch b/bin/gamelaunch
new file mode 100755 (executable)
index 0000000..aaa0c51
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+# Author: Tim Pope
+
+# Launches a game.  Works both on $1 (an argument) and $0 (the actually name
+# of the script, presumably a symlink).  Takes care of killing troublemaking
+# games, pausing unclutter, remapping the keyboard, and setting an away
+# message.
+
+pkill -INT `basename $0`-bin
+pkill -INT ut2003-bin
+pkill -INT ut2004-bin
+sleep 1
+pkill -9 `basename $0`-bin
+sync
+[ "$DISPLAY" = "127.0.0.1:7.0" ] && DISPLAY=:1.0
+
+#[ -f "$HOME/.activity" ] && mv "$HOME/.activity" "$HOME/.activity.$$.bak"
+tpope activity > "$HOME/.activity.$$.bak"
+#echo "Playing `basename $0`" > "$HOME/.activity"
+echo "Playing `basename $0`"|tpope activity -
+
+setxkbmap us
+xmodmap "$HOME/.Xmodmap" || xmodmap "$HOME/.xmodmap"
+pkill -STOP unclutter
+
+xmodmap -e "keysym Super_L = F13"
+xmodmap -e "keysym Hyper_L = F14"
+xmodmap -e "keysym Super_R = F15"
+
+for suffix in '_demo' '-demo' 'demo' ''; do
+    [ -x "/usr/local/bin/`basename $0`$suffix" ] && \
+       binary=/usr/local/bin/`basename $0`$suffix
+done
+
+if [ "`basename $0`" = gamelaunch ]; then
+    binary="$1"
+    shift
+fi
+
+$binary "$@" 2>&1 | tee "$HOME/.`basename $binary`.log"
+
+pkill -CONT unclutter
+setxkbmap us
+xmodmap "$HOME/.Xmodmap" || xmodmap "$HOME/.xmodmap"
+
+#rm -f "$HOME/.activity"
+#[ -f "$HOME/.activity.$$.bak" ] && mv "$HOME/.activity.$$.bak" "$HOME/.activity"
+cat "$HOME/.activity.$$.bak"|tpope activity -
+rm -f "$HOME/.activity.$$.bak"