#!/bin/csh

# This player is based on an idea by Michael Leslie.
#
# First, create a file with the word "ESOUND" on the
# first line and the name of a computer on which
# esound is running on the second line. Then open it
# in xmms and, voila!, you can hear what's going into
# the soundcard of that computer :-)
#
# 2002-07-10: Replaced the "cat $2" by "head -c 100 $2"
# since it could be both useless (the ESOUND word is
# supposed to be at the beginning) and dangerous (it
# *will* hang on infinite files like /dev/dsp) to
# parse the whole file.

switch ($1)
	
	case play:
		esdrec -s `head -n 2 $2 | tail -n 1`
		exit 0
	breaksw
	
	case isOurFile:
		if ( { ( head -c 100 "$2" | grep -q "ESOUND" ) } ) then
			exit 0
		else
			exit -1
		endif
	breaksw
	
endsw

exit -1
