Merge pull request #550 from kyrias/battery-notif

Battery notification timeout
This commit is contained in:
enkore 2017-03-03 22:01:59 +01:00 committed by GitHub
commit b0fdbfde3e
2 changed files with 4 additions and 2 deletions

View File

@ -174,6 +174,7 @@ class BatteryChecker(IntervalModule):
("critical_level_command", "Runs a shell command in the case of a critical power state"), ("critical_level_command", "Runs a shell command in the case of a critical power state"),
"critical_level_percentage", "critical_level_percentage",
"alert_percentage", "alert_percentage",
"alert_timeout",
("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 and specify the full path for a single battery"), ("path", "Override the default-generated path and specify the full path for a single battery"),
@ -203,6 +204,7 @@ class BatteryChecker(IntervalModule):
critical_level_command = "" critical_level_command = ""
critical_level_percentage = 1 critical_level_percentage = 1
alert_percentage = 10 alert_percentage = 10
alert_timeout = -1
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" color = "#ffffff"
@ -339,7 +341,7 @@ class BatteryChecker(IntervalModule):
body=formatp(self.alert_format_body, **fdict), body=formatp(self.alert_format_body, **fdict),
icon="battery-caution", icon="battery-caution",
urgency=2, urgency=2,
timeout=60, timeout=self.alert_timeout,
).display() ).display()
fdict["status"] = self.status[fdict["status"]] fdict["status"] = self.status[fdict["status"]]

View File

@ -13,7 +13,7 @@ class BaseDesktopNotification:
""" """
def __init__(self, title, body, icon="dialog-information", urgency=1, def __init__(self, title, body, icon="dialog-information", urgency=1,
timeout=0, log_level=logging.WARNING): timeout=-1, log_level=logging.WARNING):
self.title = title self.title = title
self.body = body self.body = body
self.icon = icon self.icon = icon