Add support for depleted batteries
This commit adds support for detecting depleted (empty) batteries. Introduces new 'Depleted' battery status and a 'DPL' status mapping.
This commit is contained in:
parent
0ff58efc69
commit
c6c7e162b3
@ -51,6 +51,8 @@ class Battery:
|
|||||||
def status(self):
|
def status(self):
|
||||||
if self.consumption() > 0.1 and self.percentage() < 99.9:
|
if self.consumption() > 0.1 and self.percentage() < 99.9:
|
||||||
return "Discharging" if self.battery_info["STATUS"] == "Discharging" else "Charging"
|
return "Discharging" if self.battery_info["STATUS"] == "Discharging" else "Charging"
|
||||||
|
elif self.consumption() == 0 and self.percentage() == 0.00:
|
||||||
|
return "Depleted"
|
||||||
else:
|
else:
|
||||||
return "Full"
|
return "Full"
|
||||||
|
|
||||||
@ -125,7 +127,7 @@ class BatteryChecker(IntervalModule):
|
|||||||
("alert_format_title", "The title of the notification, all formatters can be used"),
|
("alert_format_title", "The title of the notification, all formatters can be used"),
|
||||||
("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 ('DPL', 'DIS', 'CHR', 'FULL') to alternative names"),
|
||||||
("color", "The text color"),
|
("color", "The text color"),
|
||||||
("full_color", "The full color"),
|
("full_color", "The full color"),
|
||||||
("charging_color", "The charging color"),
|
("charging_color", "The charging color"),
|
||||||
@ -137,6 +139,7 @@ class BatteryChecker(IntervalModule):
|
|||||||
battery_ident = "BAT0"
|
battery_ident = "BAT0"
|
||||||
format = "{status} {remaining}"
|
format = "{status} {remaining}"
|
||||||
status = {
|
status = {
|
||||||
|
"DPL": "DPL",
|
||||||
"CHR": "CHR",
|
"CHR": "CHR",
|
||||||
"DIS": "DIS",
|
"DIS": "DIS",
|
||||||
"FULL": "FULL",
|
"FULL": "FULL",
|
||||||
@ -201,6 +204,9 @@ class BatteryChecker(IntervalModule):
|
|||||||
else:
|
else:
|
||||||
fdict["status"] = "CHR"
|
fdict["status"] = "CHR"
|
||||||
color = self.charging_color
|
color = self.charging_color
|
||||||
|
elif status == 'Depleted':
|
||||||
|
fdict["status"] = "DPL"
|
||||||
|
color = self.critical_color
|
||||||
else:
|
else:
|
||||||
fdict["status"] = "FULL"
|
fdict["status"] = "FULL"
|
||||||
color = self.full_color
|
color = self.full_color
|
||||||
|
Loading…
Reference in New Issue
Block a user