This commit is contained in:
enkore 2013-02-11 21:09:53 +01:00
parent db94df07a3
commit 807eb937fd
2 changed files with 11 additions and 4 deletions

View File

@ -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):

View File

@ -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: