From ac6efa0dc2a61bfa312e9cad3370d44f04b33608 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 29 May 2019 21:40:55 -0300 Subject: [PATCH 1/2] backlight: Fix AttributeError exception in desktops has_xbacklight attribute would not be set in the cases where the user does not have a backlight (i.e. Desktop), causing an exception. --- i3pystatus/backlight.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i3pystatus/backlight.py b/i3pystatus/backlight.py index 89e144fb..ae6b8719 100644 --- a/i3pystatus/backlight.py +++ b/i3pystatus/backlight.py @@ -44,6 +44,8 @@ class Backlight(File): on_downscroll = "darker" def init(self): + self.has_xbacklight = shutil.which("xbacklight") is not None + self.base_path = self.base_path.format(backlight=self.backlight) backlight_entries = sorted(glob.glob(self.base_path)) @@ -53,7 +55,6 @@ def init(self): return self.base_path = backlight_entries[0] - self.has_xbacklight = shutil.which("xbacklight") is not None # xbacklight expects a percentage as parameter. Calculate the percentage # for one step (if smaller xbacklight doesn't increases the brightness) From 51bc121fcf00edf9d4f714d8eefd475a5b3413d7 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 29 May 2019 21:46:23 -0300 Subject: [PATCH 2/2] backlight: Remove format_no_backlight empty check This check wouldn't allow the user to set format_no_backlight to empty string, not allowing the user to hide this widget if there is no need (i.e. Desktop). --- i3pystatus/backlight.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/i3pystatus/backlight.py b/i3pystatus/backlight.py index ae6b8719..862b5303 100644 --- a/i3pystatus/backlight.py +++ b/i3pystatus/backlight.py @@ -76,13 +76,9 @@ def run_no_backlight(self): "percentage": -1 } - format = self.format_no_backlight - if not format: - format = self.format - self.data = cdict self.output = { - "full_text": format.format(**cdict), + "full_text": self.format_no_backlight.format(**cdict), "color": self.color }