#!/bin/bash # Name: newmail # Purpose: Flash a message of newmail for 4 sec and go if new mail arrives # or if mail has been read # Syntax: newmail # --------------------------------------------------------------------------------- # Declare the display function flash () { xmessage -center -fn 9x15 "$1" & } # # Create an endless loop while [ "1" ] ; do # Check if any mail at all is present if (mail -H &>/dev/null) ; then mailnow=$(mail -H | wc -l) if [ "$mailnow" -gt "$lastmail" ] ; then # How many new mails? newmails=$[$mailnow-$lastmail] # Show the message flash "You have $newmails New Mail" sleep 4 kill $! elif [ "$mailnow" -lt "$lastmail" ] ; then # How many mail Read? mailread=$[$lastmail-$newmail] flash "You have $mailread less mails" sleep 4 kill $! fi # Actualize the counter lastmail=$mailnow fi sleep 1 done