Mail checkers

Mail checkers are not separate modules anymore; there is only one
mail checker module (called mail) that can make use of various backends
, which were formerly modules on their own.

This greatly simplifies code and reduces redundance.

This commit only contains the base classes for this.
This commit is contained in:
enkore 2013-02-23 15:16:23 +01:00
parent 7c8fcb8758
commit 7fceb73ff3

View File

@ -0,0 +1,31 @@
from i3pystatus import SettingsBase, IntervalModule
class Backend(SettingsBase):
"""Handle the details of checking for mail"""
unread = 0
"""Return number of unread mails
You'll probably implement that as a property"""
class Mail(IntervalModule):
settings = ("backends", "color",)
required = ("backends",)
def run(self):
unread = sum(lambda backend: backend.unread, self.backends)
if (unread == 0):
color = "#00FF00"
urgent = "false"
else:
color = "#ff0000"
urgent = "true"
self.output = {
"full_text" : "%d new email%s" % (unread, ("s" if unread > 1 else "")),
"name" : "newmail",
"urgent" : urgent,
"color" : color
}