]> git.llucax.com Git - personal/ion3-config.git/blob - maildir_status_server.sh
b831866af1081481c33fb63d371c64fdc3c49d74
[personal/ion3-config.git] / maildir_status_server.sh
1 #!/bin/sh
2 #set -x
3
4 delay=30
5 maildir=~/Maildir
6
7 [ -n "$1" ] && delay="$1"
8 [ -n "$2" ] && maildir="$2"
9
10 cd $maildir
11 maildirs=`find -type d -name new | grep -v historial`
12
13 print_status()
14 {
15
16         messages=
17         for d in $maildirs
18         do
19                 msgs=`ls $d | wc -l`
20                 if [ $msgs -gt 0 ]
21                 then
22                         name=`dirname $d`
23                         name=`basename $name | cut -b2-`
24                         [ -z "$name" ] && name=Inbox
25                         messages="$messages $name ($msgs)"
26                 fi
27         done
28         if [ -n "$messages" ]
29         then
30                 echo $messages
31         else
32                 echo "nada nuevo"
33         fi
34 }
35
36 print_status
37 while sleep $delay
38 do
39         print_status
40 done
41