Remove TODO, found a better way
This commit is contained in:
parent
1009901e3b
commit
602da44765
41
notmuchmailchecker.py
Normal file
41
notmuchmailchecker.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import json
|
||||
from datetime import datetime,timedelta
|
||||
import notmuch
|
||||
|
||||
class NotmuchMailChecker(object):
|
||||
"""
|
||||
This class checks for the number of unread messages in the notmuch
|
||||
database using the notmuch python bindings
|
||||
"""
|
||||
|
||||
settings = {
|
||||
'color': '#ff0000',
|
||||
'servers': []
|
||||
}
|
||||
|
||||
db_path = ''
|
||||
|
||||
servers = []
|
||||
|
||||
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 }
|
Loading…
Reference in New Issue
Block a user