#!/bin/sh # $Id$ # -*- sh -*- vim: ft=sh sw=4 sts=4 # Launches a game. Works both on $1 (an argument) and $0 (the actual 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 [ "$DISPLAY" = "127.0.0.1:7.0" ] && DISPLAY=:1.0 for suffix in '_demo' '-demo' 'demo' ''; do [ -x "/usr/games/`basename $0`$suffix" ] && \ binary="/usr/games/`basename $0`$suffix" [ -x "/usr/local/bin/`basename $0`$suffix" ] && \ binary="/usr/local/bin/`basename $0`$suffix" done if [ "`basename $0`" = gamelaunch ]; then binary="$1" shift fi pkill -9 `basename $binary`-bin sync setxkbmap us xmodmap "$HOME/.Xmodmap" 2> /dev/null || xmodmap "$HOME/.xmodmap" pkill -STOP unclutter if [ "`basename $binary`" = doom3 ]; then xset m 2 4 xmodmap -e "keysym Super_L = KP_5" xmodmap -e "keysym Hyper_L = KP_Insert" xmodmap -e "keysym Super_R = F11" else xmodmap -e "keysym Super_L = F13" xmodmap -e "keysym Hyper_L = F14" xmodmap -e "keysym Super_R = F15" fi tpope activity > "$HOME/.activity.$$.bak" echo "Playing `basename $binary`"|tpope activity - $binary "$@" 2>&1 | tee "$HOME/.`basename $binary`.log" pkill -CONT unclutter setxkbmap us xmodmap "$HOME/.Xmodmap" || xmodmap "$HOME/.xmodmap" xset m 3 3 #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"