#!/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, setting an away message, # and anything else that needs to be done. basename="`basename $0`" if [ "$basename" = gamelaunch ]; then if [ "x$1" = x--name ]; then shift name="$1" shift fi binary="$1" basename="`basename $binary`" shift fi pkill -INT "^$basename-bin\$" && sleep 1 pkill -INT "^ut2004-bin\$" && sleep 1 pkill -KILL "^$basename-bin\$" sync [ "$DISPLAY" = "127.0.0.1:7.0" ] && DISPLAY=:1.0 game="${name:-$basename}" if [ -f "$HOME/games/names.txt" ] && grep -i "^$game=" "$HOME/games/names.txt" >/dev/null; then game="`grep "^$game=" "$HOME/games/names.txt"|sed -e 's/^[^=]*=//g'`" elif [ -z "$name" ]; then game="`echo $game|sed -e 's/\(^\|[-_. ]\)\(.\)/ \U\2/g' -e 's/\([a-z]\)\([0-9]\)/\1 \2/' -e 's/ \([EU]\)t\>/ \1T/' -e 's/^ //'`" fi for suffix in '_demo' '-demo' 'demo' ''; do [ -x "/usr/bin/$basename$suffix" ] && \ binary="/usr/bin/$basename$suffix" [ -x "/usr/games/$basename$suffix" ] && \ binary="/usr/games/$basename$suffix" [ -x "/usr/local/bin/$basename$suffix" ] && \ binary="/usr/local/bin/$basename$suffix" done if [ -z "$binary" ]; then echo "Game not found." >&2 exit 1 fi setxkbmap us xmodmap "$HOME/.Xmodmap" 2>/dev/null || xmodmap "$HOME/.xmodmap" skill -STOP unclutter case "$basename" in ut2004|quake3|doom3|et|armyops) xmodmap -e "keysym Super_L = F13" xmodmap -e "keysym Hyper_L = F14" xmodmap -e "keysym Super_R = F15" ;; esac activity="`tpope status activity`" if [ -n "$game" ]; then tpope status activity "Playing $game" fi if lspci 2>/dev/null|grep 'VT8233/A/8235/8237' >/dev/null; then SDL_DSP_NOSELECT=1 export SDL_DSP_NOSELECT sh -c "(sleep 2; amixer sset IEC958 unmute >/dev/null) &" fi if lspci 2>/dev/null|grep 'Savage 3D' >/dev/null; then s3="`s3switch|grep 'Devices active:'|sed -e 's/Devices active: *//'`" s3switch TV >/dev/null fi on_exit() { [ -z "$sdpid" ] || kill "$sdpid" skill -CONT unclutter setxkbmap us xmodmap "$HOME/.Xmodmap" 2>/dev/null || xmodmap "$HOME/.xmodmap" xset m 3 3 [ -z "$s3" ] || s3switch $s3 >/dev/null FvwmCommand "GoToDeskAndPage 0 0 0" >/dev/null 2>&1 tpope status activity "$activity" } trap on_exit EXIT FvwmCommand "GoToDeskAndPage 0 2 2" >/dev/null 2>&1 tpope display-manage $binary "$@" # 2>&1