-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewmail.sh
More file actions
executable file
·49 lines (40 loc) · 1008 Bytes
/
newmail.sh
File metadata and controls
executable file
·49 lines (40 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
MAILLOG=/tmp/new-mail
TMPLOG=/tmp/new-mail-work
rm -rf $TMPLOG
TITLE="Unread mail items:"
echo $TITLE > $MAILLOG
MAIL_DIR=~/Mail/RH
COUNT=0
for dir in $(find $MAIL_DIR -type d -name new | grep -v " ")
do
cd $dir
NEW=$(find -type f | wc -l)
if [ $NEW -gt 0 ]
then
FOLDER=$(echo ${PWD} | rev | cut -d / -f 2 | rev)
echo $FOLDER: $NEW >> $TMPLOG
COUNT=$(( COUNT + $NEW ))
fi
done
if [ $COUNT -gt 0 ]
then
# dbus notification
sed -i 's/items:/items: '$COUNT'/g' $MAILLOG
notify-send "NEW MAIL" "$TITLE $COUNT"
# zenity window
sort $TMPLOG | uniq >> $MAILLOG
for PID in $(ps -ef | grep -v grep | grep zenity | awk '{print $2}')
do
kill -9 $PID
done
zenity --text-info --title "Unread mail items: $COUNT" --filename $MAILLOG &
# ding
if [ $COUNT -ne 0 ]
then
play /usr/share/sounds/freedesktop/stereo/message.oga
fi
else
sed -i 's/items:/items: 0/g' $MAILLOG
fi
rm -rf $TMPLOG