added thunderbird new mail checker.

This commit is contained in:
Jan Oliver Oelerich 2012-11-17 12:39:41 +01:00
parent 68ceafe969
commit 944613de3a
2 changed files with 58 additions and 1 deletions

51
thunderbirdnewmail.py Normal file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# This plugin listens for dbus signals emitted by the
# thunderbird-dbus-sender extension for TB:
# https://github.com/janoliver/thunderbird-dbus-sender
# The plugin must be active and thunderbird running for the module to work
# properly.
import dbus, gobject
from dbus.mainloop.glib import DBusGMainLoop
import json
class ThunderbirdMailChecker(object):
"""
This class listens for dbus signals emitted by
the dbus-sender extension for thunderbird.
"""
unread = []
def __init__(self):
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(self.new_msg,
dbus_interface="org.mozilla.thunderbird.DBus",
signal_name="NewMessageSignal")
bus.add_signal_receiver(self.changed_msg,
dbus_interface="org.mozilla.thunderbird.DBus",
signal_name="ChangedMessageSignal")
loop = gobject.MainLoop()
dbus.mainloop.glib.threads_init()
self.context = loop.get_context()
def new_msg(self, id, author, subject):
if id not in self.unread:
self.unread.append(id)
def changed_msg(self, id, event):
if event == "read" and id in self.unread:
self.unread.remove(id)
def output(self):
self.context.iteration(False)
unread = len(self.unread)
return {'full_text' : '%d new email' % unread,
'name' : 'newmail-tb',
'urgent' : True,
'color' : '#ff0000' } if unread else None

View File

@ -10,7 +10,7 @@ if __name__ == '__main__':
status = I3statusHandler()
#List the modules
# The imap checker module
mailsettings = {
'color': '#ff0000',
'servers': [
@ -35,6 +35,7 @@ if __name__ == '__main__':
mailchecker = mailchecker.MailChecker(mailsettings)
status.register_module(mailchecker)
# the mods.de forum new bookmarks module
mdesettings = {
'username': "your_username",
'password': "your_password"
@ -42,9 +43,14 @@ if __name__ == '__main__':
mde = modsde.ModsDeChecker(mdesettings)
status.register_module(mde)
# the notmuch mail checker module
db_path = 'path_to_your_notmuch_database'
notmuch = notmuchmailchecker.NotmuchMailChecker(db_path)
status.register_module(notmuch)
# the thunderbird dbus new mail checker module
tb = thunderbirdnewmail.ThunderbirdMailChecker()
status.register_module(tb)
# start the handler
status.run()