Reworked that (again)
This commit is contained in:
parent
d4f1c77c85
commit
d3228cc8be
@ -7,15 +7,17 @@
|
|||||||
# The plugin must be active and thunderbird running for the module to work
|
# The plugin must be active and thunderbird running for the module to work
|
||||||
# properly.
|
# properly.
|
||||||
|
|
||||||
import dbus, gobject
|
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
|
||||||
import json
|
import json
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from i3pystatus import AsyncModule
|
import dbus, gobject
|
||||||
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
|
|
||||||
class ThunderbirdMailChecker(AsyncModule):
|
from i3pystatus import IntervalModule
|
||||||
|
|
||||||
|
class ThunderbirdMailChecker(IntervalModule):
|
||||||
"""
|
"""
|
||||||
This class listens for dbus signals emitted by
|
This class listens for dbus signals emitted by
|
||||||
the dbus-sender extension for thunderbird.
|
the dbus-sender extension for thunderbird.
|
||||||
@ -24,8 +26,8 @@ class ThunderbirdMailChecker(AsyncModule):
|
|||||||
settings = {
|
settings = {
|
||||||
"format": "%d new email"
|
"format": "%d new email"
|
||||||
}
|
}
|
||||||
|
|
||||||
unread = set()
|
unread = set()
|
||||||
|
interval = 1
|
||||||
|
|
||||||
def __init__(self, settings=None):
|
def __init__(self, settings=None):
|
||||||
if settings is not None:
|
if settings is not None:
|
||||||
@ -43,10 +45,7 @@ class ThunderbirdMailChecker(AsyncModule):
|
|||||||
dbus.mainloop.glib.threads_init()
|
dbus.mainloop.glib.threads_init()
|
||||||
self.context = loop.get_context()
|
self.context = loop.get_context()
|
||||||
|
|
||||||
def mainloop(self):
|
self.run = partial(self.context.iteration, False)
|
||||||
while True:
|
|
||||||
self.context.iteration(False)
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
def new_msg(self, id, author, subject):
|
def new_msg(self, id, author, subject):
|
||||||
if id not in self.unread:
|
if id not in self.unread:
|
||||||
@ -59,7 +58,7 @@ class ThunderbirdMailChecker(AsyncModule):
|
|||||||
self._output()
|
self._output()
|
||||||
|
|
||||||
def _output(self):
|
def _output(self):
|
||||||
self.context.iteration(False)
|
self.run()
|
||||||
|
|
||||||
unread = len(self.unread)
|
unread = len(self.unread)
|
||||||
if unread:
|
if unread:
|
||||||
|
Loading…
Reference in New Issue
Block a user