},
},
maildir = {
- program = '~/.ion3/maildir_status_server.sh 10',
- retry_delay = 10 * 1000,
+ program = '~/.ion3/maildir_status_server.py 10', -- 10 segundos
+ retry_delay = 10 * 1000, -- 10 segundos
hint_regexp = {
important = '([0-9]+)',
},
--- /dev/null
+#!/usr/bin/env python2.5
+
+import os
+import re
+import sys
+import glob
+import time
+
+# MUST config
+maildir = os.path.join(os.getenv('HOME'), 'Maildir')
+
+# MAY config
+no_template = 'nada nuevo'
+yes_template = '%(name)s (%(messages)s)'
+join_str = ' '
+default_secs = 30
+
+if len(sys.argv) > 1:
+ secs = int(sys.argv[1])
+
+os.chdir(maildir)
+
+folders = [f for f in glob.glob(os.path.join(maildir, '.*'))
+ if not f.endswith('.historial')
+ and os.path.exists(os.path.join(f, 'new'))]
+folders.sort()
+folders.insert(0, maildir)
+
+while True:
+ new = []
+ for folder in folders:
+ name = folder[len(maildir)+2:]
+ if not name: name = 'INBOX'
+ messages = len(glob.glob(os.path.join(folder, 'new', '*')))
+ if messages:
+ new.append((name, messages))
+ if new:
+ print join_str.join([yes_template % dict(name=n, messages=m)
+ for (n,m) in new])
+ else:
+ print no_template
+ sys.stdout.flush()
+ time.sleep(secs)
+
+++ /dev/null
-#!/bin/sh
-#set -x
-
-delay=30
-maildir=~/Maildir
-
-[ -n "$1" ] && delay="$1"
-[ -n "$2" ] && maildir="$2"
-
-cd $maildir
-maildirs=`find -type d -name new | grep -v historial`
-
-print_status()
-{
-
- messages=
- for d in $maildirs
- do
- msgs=`ls $d | wc -l`
- if [ $msgs -gt 0 ]
- then
- name=`dirname $d`
- name=`basename $name | cut -b2-`
- [ -z "$name" ] && name=Inbox
- messages="$messages $name ($msgs)"
- fi
- done
- if [ -n "$messages" ]
- then
- echo $messages
- else
- echo "nada nuevo"
- fi
-}
-
-print_status
-while sleep $delay
-do
- print_status
-done
-