commit
68ceafe969
35
notmuchmailchecker.py
Normal file
35
notmuchmailchecker.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# note that this needs the notmuch python bindings. For more info see:
|
||||||
|
# http://notmuchmail.org/howto/#index4h2
|
||||||
|
import notmuch
|
||||||
|
import json
|
||||||
|
|
||||||
|
class NotmuchMailChecker(object):
|
||||||
|
"""
|
||||||
|
This class uses the notmuch python bindings to check for the
|
||||||
|
number of messages in the notmuch database with the tags "inbox"
|
||||||
|
and "unread"
|
||||||
|
"""
|
||||||
|
|
||||||
|
db_path = ''
|
||||||
|
|
||||||
|
def __init__(self, db_path):
|
||||||
|
self.db_path = db_path
|
||||||
|
|
||||||
|
def output(self):
|
||||||
|
db = notmuch.Database(self.db_path)
|
||||||
|
unread = notmuch.Query(db, 'tag:unread and tag:inbox').count_messages()
|
||||||
|
|
||||||
|
if (unread == 0):
|
||||||
|
color = '#00FF00'
|
||||||
|
urgent = 'false'
|
||||||
|
else:
|
||||||
|
color = '#ff0000'
|
||||||
|
urgent = 'true'
|
||||||
|
|
||||||
|
return {'full_text' : '%d new email%s' % (unread, ('s' if unread > 1 else '')),
|
||||||
|
'name' : 'newmail',
|
||||||
|
'urgent' : urgent,
|
||||||
|
'color' : color }
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import mailchecker
|
import mailchecker
|
||||||
import modsde
|
import modsde
|
||||||
|
import notmuchmailchecker
|
||||||
from statushandler import I3statusHandler
|
from statushandler import I3statusHandler
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -41,5 +42,9 @@ if __name__ == '__main__':
|
|||||||
mde = modsde.ModsDeChecker(mdesettings)
|
mde = modsde.ModsDeChecker(mdesettings)
|
||||||
status.register_module(mde)
|
status.register_module(mde)
|
||||||
|
|
||||||
|
db_path = 'path_to_your_notmuch_database'
|
||||||
|
notmuch = notmuchmailchecker.NotmuchMailChecker(db_path)
|
||||||
|
status.register_module(notmuch)
|
||||||
|
|
||||||
# start the handler
|
# start the handler
|
||||||
status.run()
|
status.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user