Search /usr/games in addition to /usr/local/bin
[tpope-extra.git] / bin / gamelaunch
1 #!/bin/sh
2 # $Id$
3 # -*- sh -*- vim: ft=sh sw=4 sts=4
4
5 # Launches a game.  Works both on $1 (an argument) and $0 (the actual name
6 # of the script, presumably a symlink).  Takes care of killing troublemaking
7 # games, pausing unclutter, remapping the keyboard, and setting an away
8 # message.
9
10 pkill -INT `basename $0`-bin
11 pkill -INT ut2003-bin
12 pkill -INT ut2004-bin
13 sleep 1
14 pkill -9 `basename $0`-bin
15 sync
16 [ "$DISPLAY" = "127.0.0.1:7.0" ] && DISPLAY=:1.0
17
18 #[ -f "$HOME/.activity" ] && mv "$HOME/.activity" "$HOME/.activity.$$.bak"
19 tpope activity > "$HOME/.activity.$$.bak"
20 #echo "Playing `basename $0`" > "$HOME/.activity"
21 echo "Playing `basename $0`"|tpope activity -
22
23 setxkbmap us
24 xmodmap "$HOME/.Xmodmap" || xmodmap "$HOME/.xmodmap"
25 pkill -STOP unclutter
26
27 xmodmap -e "keysym Super_L = F13"
28 xmodmap -e "keysym Hyper_L = F14"
29 xmodmap -e "keysym Super_R = F15"
30
31 for suffix in '_demo' '-demo' 'demo' ''; do
32     [ -x "/usr/games/`basename $0`$suffix" ] && \
33         binary="/usr/games/`basename $0`$suffix"
34     [ -x "/usr/local/bin/`basename $0`$suffix" ] && \
35         binary="/usr/local/bin/`basename $0`$suffix"
36 done
37
38 if [ "`basename $0`" = gamelaunch ]; then
39     binary="$1"
40     shift
41 fi
42
43 $binary "$@" 2>&1 | tee "$HOME/.`basename $binary`.log"
44
45 pkill -CONT unclutter
46 setxkbmap us
47 xmodmap "$HOME/.Xmodmap" || xmodmap "$HOME/.xmodmap"
48
49 #rm -f "$HOME/.activity"
50 #[ -f "$HOME/.activity.$$.bak" ] && mv "$HOME/.activity.$$.bak" "$HOME/.activity"
51 cat "$HOME/.activity.$$.bak"|tpope activity -
52 rm -f "$HOME/.activity.$$.bak"