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:
parent
7c8fcb8758
commit
7fceb73ff3
31
i3pystatus/mail/__init__.py
Normal file
31
i3pystatus/mail/__init__.py
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user