From 7fceb73ff33a6799d9417dc63836b27b7ff7c50f Mon Sep 17 00:00:00 2001 From: enkore Date: Sat, 23 Feb 2013 15:16:23 +0100 Subject: [PATCH] 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. --- i3pystatus/mail/__init__.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 i3pystatus/mail/__init__.py diff --git a/i3pystatus/mail/__init__.py b/i3pystatus/mail/__init__.py new file mode 100644 index 0000000..a141a29 --- /dev/null +++ b/i3pystatus/mail/__init__.py @@ -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 + }