aboutsummaryrefslogtreecommitdiff
path: root/local/sbin/newmail-notify
blob: 65655b49291c8b008bf1b965b9956a1adc5782c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

cd ~/.mail

if [ -f notify-notified ]; then
	NOTIFIED=`cat notify-notified`
	rm notify-notified
fi

for account in `ls`; do
	if cd "$account"/INBOX/new; then
		for m in `ls`; do
			echo $m
			echo $m >> ~/.mail/notify-notified
			if echo "$NOTIFIED" | grep "$m" >/dev/null; then continue; fi
			FROM=`grep -E "^From: " "$m" | sed 's/^From: //'`
			SUBJECT=`grep -E "^Subject: " "$m" | sed 's/^Subject: //'`
			notify-send "Email: $account" "$FROM: $SUBJECT"
		done
	fi
	cd ~/.mail
done