#!/bin/sh # Evolution mail checker. Requires: # xwit, touch, awk, grep, xprop, play and a WAV file. # xwit can be had from http://olliver.family.gen.nz/software # # Check for mail by seeing if the time on ~/evolution/local/Inbox/mbox changes export mailcheckerfile=$HOME/evolution/local/Inbox/mbox # Make sure file exists touch /tmp/mailchecker_old.$USER while (true); do sleep 10 ls -l $mailcheckerfile|awk '{print $5}' >/tmp/mailchecker_new.$USER /usr/bin/diff -q /tmp/mailchecker_new.$USER /tmp/mailchecker_old.$USER>/dev/null if [ $? != 0 ]; then # We've a change in the mail file. Play alert message anyway play /DOSC/windows/simpmail.wav & # Test file to see if a window is iconic # Bodge required to test on window 'id' as xprop is broken when using 'name' tgtWindowId=`xprop -name evolution|grep "WM_TRANSIENT_FOR"|awk '{print $5}'` tgtWindowState=`xprop -id $tgtWindowId WM_STATE|grep "window state"|awk '{print $3}'` if [ "$tgtWindowState" == "Iconic" ]; then xmessage -center "You have mail!" xwit -pop -names Inbox fi cp /tmp/mailchecker_new.$USER /tmp/mailchecker_old.$USER fi done