diff --git a/statushandler.py b/statushandler.py index 4b2e53f..326fc12 100644 --- a/statushandler.py +++ b/statushandler.py @@ -11,7 +11,7 @@ class Module(object): def registered(self, status_handler): """Called when this module is registered with a status handler""" - def run(self): + def tick(self): """Only called if self.async == False. Called once per tick""" class I3statusHandler(object): diff --git a/thunderbirdnewmail.py b/thunderbirdnewmail.py index 96e5d53..d6171d3 100644 --- a/thunderbirdnewmail.py +++ b/thunderbirdnewmail.py @@ -11,6 +11,7 @@ import dbus, gobject from dbus.mainloop.glib import DBusGMainLoop import json import threading +import time class ThunderbirdMailChecker(object): """ @@ -18,7 +19,7 @@ class ThunderbirdMailChecker(object): the dbus-sender extension for thunderbird. """ - async = False + async = True output = None unread = set() @@ -36,8 +37,14 @@ class ThunderbirdMailChecker(object): dbus.mainloop.glib.threads_init() self.context = loop.get_context() - def tick(self): - self.context.iteration(False) + self.thread = threading.Thread(target=self.mainloop) + self.thread.daemon = True + self.thread.start() + + def mainloop(self): + while True: + self.context.iteration(False) + time.sleep(1) def new_msg(self, id, author, subject): if id not in self.unread: