#!/bin/sh
# Nico Schottelius
# 10-Jan-2003
# startup locked playing for the login process
#

LOCKFILE=~/.greet.lock
PID=`cat $LOCKFILE 2>/dev/null` 
PLAYER="tracker"
FILE=~/pub/computer/audio/music/mods/cold_blood.mod

trap "rm -f $LOCKFILE; exit 1" ALRM HUP INT KILL TERM

if [ -f "$LOCKFILE" ]; then
   echo runtest
   # check if process still exists, then exit
   kill -WINCH $PID 2>/dev/null && exit 0
   echo seems not run
fi

# this is wrong, but kill sees we exist now
echo $$ > "$LOCKFILE"

# startup playing & automatic cleanup
(
   "$PLAYER" "$FILE" &>/dev/null
   rm -f "$LOCKFILE"
) &
   
##"$PLAYER" "$FILE" &>/dev/null &

# set the correct lockpid: $! is wrong...
echo $! > $LOCKFILE

##fg
##rm -f "$LOCKFILE"