Format settings

This commit is contained in:
enkore 2013-02-11 21:25:14 +01:00
parent 2c97a67494
commit 484cfbbf03
2 changed files with 18 additions and 10 deletions

View File

@ -9,9 +9,6 @@ import re
import http.cookiejar
import xml.etree.ElementTree as ET
class LoginError(Exception):
pass
class ModsDeChecker(object):
"""
This class returns i3status parsable output of the number of
@ -33,6 +30,7 @@ class ModsDeChecker(object):
"username": "",
"password": "",
"offset": 0,
"format": "%d new posts in bookmarks"
}
def __init__(self, settings = None):
@ -51,10 +49,12 @@ class ModsDeChecker(object):
if not unread:
self.output = None
else:
self.output = {"full_text" : "%d new posts in bookmarks" % unread,
self.output = {
"full_text" : self.settings["format"] % unread,
"name" : "modsde",
"urgent" : "true",
"color" : self.settings["color"]}
"color" : self.settings["color"]
}
time.sleep(self.settings["pause"])

View File

@ -22,9 +22,15 @@ class ThunderbirdMailChecker(object):
async = True
output = None
settings = {
"format": "%d new email"
}
unread = set()
def __init__(self):
def __init__(self, settings):
self.settings.update(settings)
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(self.new_msg,
@ -61,10 +67,12 @@ class ThunderbirdMailChecker(object):
unread = len(self.unread)
if unread:
self.output = {'full_text' : '%d new email' % unread,
'name' : 'newmail-tb',
'urgent' : True,
'color' : '#ff0000' }
self.output = {
"full_text": self.settings["format"] % unread,
"name": "newmail-tb",
"urgent": True,
"color": "#ff0000",
}
else:
self.output = None