Make battery colors configurable

This commit is contained in:
Stéphane Brunner 2014-04-16 17:34:48 +02:00
parent 5aef5f529a
commit 6d8dba3468
2 changed files with 9 additions and 3 deletions

View File

@ -115,6 +115,8 @@ class BatteryChecker(IntervalModule):
("alert_format_body", "The body text of the notification, all formatters can be used"), ("alert_format_body", "The body text of the notification, all formatters can be used"),
("path", "Override the default-generated path"), ("path", "Override the default-generated path"),
("status", "A dictionary mapping ('DIS', 'CHR', 'FULL') to alternative names"), ("status", "A dictionary mapping ('DIS', 'CHR', 'FULL') to alternative names"),
("color", "The text color"),
("critical_color", "The critical color"),
) )
battery_ident = "BAT0" battery_ident = "BAT0"
format = "{status} {remaining}" format = "{status} {remaining}"
@ -128,6 +130,8 @@ class BatteryChecker(IntervalModule):
alert_percentage = 10 alert_percentage = 10
alert_format_title = "Low battery" alert_format_title = "Low battery"
alert_format_body = "Battery {battery_ident} has only {percentage:.2f}% ({remaining:%E%hh:%Mm}) remaining!" alert_format_body = "Battery {battery_ident} has only {percentage:.2f}% ({remaining:%E%hh:%Mm}) remaining!"
color = "#ffffff"
critical_color = "#ff0000"
path = None path = None
@ -138,7 +142,7 @@ class BatteryChecker(IntervalModule):
def run(self): def run(self):
urgent = False urgent = False
color = "#ffffff" color = self.color
battery = Battery.create(self.path) battery = Battery.create(self.path)
@ -158,7 +162,7 @@ class BatteryChecker(IntervalModule):
fdict["status"] = "DIS" fdict["status"] = "DIS"
if battery.percentage() <= self.alert_percentage: if battery.percentage() <= self.alert_percentage:
urgent = True urgent = True
color = "#ff0000" color = self.critical_color
else: else:
fdict["status"] = "CHR" fdict["status"] = "CHR"
else: else:
@ -179,5 +183,5 @@ class BatteryChecker(IntervalModule):
"full_text": formatp(self.format, **fdict).strip(), "full_text": formatp(self.format, **fdict).strip(),
"instance": self.battery_ident, "instance": self.battery_ident,
"urgent": urgent, "urgent": urgent,
"color": color "color": color,
} }

View File

@ -11,6 +11,8 @@ class Load(IntervalModule):
settings = ( settings = (
("format", ("format",
"format string used for output. {avg1}, {avg5} and {avg15} are the load average of the last one, five and fifteen minutes, respectively. {tasks} is the number of tasks (i.e. 1/285, which indiciates that one out of 285 total tasks is runnable)."), "format string used for output. {avg1}, {avg5} and {avg15} are the load average of the last one, five and fifteen minutes, respectively. {tasks} is the number of tasks (i.e. 1/285, which indiciates that one out of 285 total tasks is runnable)."),
("critical_limit", "Limit under witch one the battery is critical"),
("critical_color", "The critical color"),
) )
file = "/proc/loadavg" file = "/proc/loadavg"