-- Scripts
exec = {
psi = {
- program = '~/.ion3/psi_status.sh',
+ program = '~/.ion3/psi_status_server.py 1', -- 1 segundo
retry_delay = 1 * 1000, -- 1 segundo
hint_regexp = {
important = '^[0-9]',
+++ /dev/null
-#!/bin/sh
-
-psi_profile_dir=~/.psi/profiles/luca
-
-events_files="$psi_profile_dir"/events-*.xml
-regex='^\s*<jid'
-
-msgs=`egrep "$regex" $events_files | wc -l`
-jids=`egrep "$regex" $events_files \
- | sed 's/.*<jid>\(.*\)<\/jid>.*/\1/' \
- | sort -u \
- | tr '\n' ' ' \
- | sed 's/ $//'`
-if [ $msgs -eq 0 ]
-then
- echo "nada nuevo"
-else
- [ $msgs -gt 1 ] && pl=s
- echo "$msgs mensaje$pl nuevo$pl (de $jids)"
-fi
--- /dev/null
+#!/usr/bin/env python2.5
+
+import os
+import re
+import sys
+import glob
+import time
+
+# MUST config
+psi_profile = 'luca'
+
+# MAY config
+no_template = 'nada nuevo'
+yes_template = '%(total)s mensaje%(pl)s nuevo%(pl)s (de %(jids)s)'
+join_str = ' '
+default_secs = 1
+
+# Probably you don't want to touch this
+psi_profile_dir = os.path.join(os.getenv('HOME'), '.psi', 'profiles', psi_profile)
+events_files_glob = 'events-*.xml'
+event_regex = re.compile(r'.*<jid>(.*)<\/jid>.*')
+
+os.chdir(psi_profile_dir)
+
+secs = default_secs
+
+if len(sys.argv) > 1:
+ secs = int(sys.argv[1])
+
+print 'start'
+while True:
+ events = []
+ for f in glob.glob(events_files_glob):
+ l = event_regex.findall(file(f).read())
+ if l:
+ events.extend(l)
+ if events:
+ print yes_template % dict(
+ total = len(events),
+ pl = 's' if len(events) > 1 else '',
+ jids = join_str.join(frozenset(events))
+ )
+ else:
+ print no_template
+ sys.stdout.flush()
+ time.sleep(secs)
+