#!/bin/sh
RECORDFILE=/var/tmp/record.raw
OUTFILE=/var/tmp/sound.raw
NULLFILE=/var/tmp/null.raw

case "$1" in
	-on)
		echo "Erasing old recording in $OUTFILE..."
		echo -n "If OK press enter:"
		read ans
		> $OUTFILE
		ln -sf $OUTFILE $RECORDFILE
	;;
	-off)
		if [ "$(realpath $NULLFILE)" != "/dev/null" ]
		then
			rm -f $NULLFILE
			ln -s /dev/null $NULLFILE
		fi
		ln -sf $NULLFILE $RECORDFILE
		echo "Recording in the raw format 16bit 2-channel at 44.1KHz"
		echo "is in $OUTFILE and can be played with the command:"
		echo "aplay -f cd $OUTFILE"
	;;
	-show|-sh)
		ls -l $RECORDFILE
	;;
	*)
      echo "$0: -on switches on recording an -off switches it off "
	;;
esac

