#!/bin/sh
#
# Plays an audio file when new mail is received.  To hook this into
# xbiff, set the following resource:
#
#	xbiff*checkCommand:     checkmail
#
# $NCDId: @(#)checkmail,v 1.1 1994/01/18 20:07:50 greg Exp $

maildrop=/usr/spool/mail/$USER	# user's mail drop
mailstat=$HOME/.mailstat	# file to hold the previous mail drop size
mailsound=$HOME/.mailsound	# audio file to play when there's new mail

# get the previous mail drop size
if [ -f $mailstat ]; then previous=`cat $mailstat`; else previous=0; fi

# get the current mail drop size and save it
current=`wc $maildrop`; echo $current > $mailstat

if [ "$current" -eq "$previous" ]; then exit 1; fi	# nothing has changed
if [ "$current" -lt "$previous" ]; then exit 2; fi	# mail's been removed
playbucket $mailsound & exit 0				# new mail
