Thunderbird
This commit is contained in:
parent
93b7ba9af9
commit
761034dd01
@ -15,19 +15,15 @@ from functools import partial
|
|||||||
import dbus, gobject
|
import dbus, gobject
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
|
|
||||||
from i3pystatus import IntervalModule
|
from i3pystatus.mail import Backend
|
||||||
|
|
||||||
class ThunderbirdMailChecker(IntervalModule):
|
class Thunderbird(Backend):
|
||||||
"""
|
"""
|
||||||
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.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
settings = ("format",)
|
|
||||||
|
|
||||||
unread = set()
|
unread = set()
|
||||||
interval = 1
|
|
||||||
format = "%d new mail"
|
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||||
@ -47,23 +43,12 @@ class ThunderbirdMailChecker(IntervalModule):
|
|||||||
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:
|
||||||
self.unread.add(id)
|
self.unread.add(id)
|
||||||
self._output()
|
|
||||||
|
|
||||||
def changed_msg(self, id, event):
|
def changed_msg(self, id, event):
|
||||||
if event == "read" and id in self.unread:
|
if event == "read" and id in self.unread:
|
||||||
self.unread.remove(id)
|
self.unread.remove(id)
|
||||||
self._output()
|
|
||||||
|
|
||||||
def _output(self):
|
@property
|
||||||
|
def unread(self):
|
||||||
self.run()
|
self.run()
|
||||||
|
return len(self.unread)
|
||||||
unread = len(self.unread)
|
|
||||||
if unread:
|
|
||||||
self.output = {
|
|
||||||
"full_text": self.settings["format"] % unread,
|
|
||||||
"name": "newmail-tb",
|
|
||||||
"urgent": True,
|
|
||||||
"color": "#ff0000",
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
self.output = None
|
|
Loading…
Reference in New Issue
Block a user