From 19ea035e68fbec2b39420b5bfd3ab340b3d14d78 Mon Sep 17 00:00:00 2001 From: Georg Sieber Date: Fri, 5 Jun 2015 20:52:41 +0200 Subject: [PATCH 1/3] Add module for DPMS state --- i3pystatus/dpms.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 i3pystatus/dpms.py diff --git a/i3pystatus/dpms.py b/i3pystatus/dpms.py new file mode 100644 index 0000000..3c2854c --- /dev/null +++ b/i3pystatus/dpms.py @@ -0,0 +1,44 @@ +from i3pystatus import IntervalModule +from i3pystatus.core.command import run_through_shell + +class DPMS(IntervalModule): + """ + Shows and toggles status of DPMS which prevents screen from blanking. + + + .. rubric:: Available formatters + + * `{status}` — the current status of DPMS + @author Georg Sieber + """ + + interval = 5 + + settings = ( + "format", + "color", + "color_disabled", + ) + + color_disabled = "#AAAAAA" + color = "#FFFFFF" + format = "DPMS: {status}" + + on_leftclick = "toggle_dpms" + + status = False + + def run(self): + + self.status = run_through_shell("xset -q | grep -q 'DPMS is Enabled'", True).rc == 0 + + self.output = { + "full_text": self.format.format(status='on' if self.status else 'off'), + "color": self.color if self.status else self.color_disabled + } + + def toggle_dpms(self): + if self.status: + run_through_shell("xset -dpms s off", True) + else: + run_through_shell("xset +dpms s on", True) From c569dd608ffb324798adff3b34c9c53cd1016afe Mon Sep 17 00:00:00 2001 From: Georg Sieber Date: Fri, 5 Jun 2015 21:19:17 +0200 Subject: [PATCH 2/3] fixed formatting issues --- i3pystatus/dpms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i3pystatus/dpms.py b/i3pystatus/dpms.py index 3c2854c..f571f3b 100644 --- a/i3pystatus/dpms.py +++ b/i3pystatus/dpms.py @@ -1,6 +1,7 @@ from i3pystatus import IntervalModule from i3pystatus.core.command import run_through_shell + class DPMS(IntervalModule): """ Shows and toggles status of DPMS which prevents screen from blanking. @@ -17,7 +18,7 @@ class DPMS(IntervalModule): settings = ( "format", "color", - "color_disabled", + "color_disabled", ) color_disabled = "#AAAAAA" From 2fe7ad1c41532b933105831e3a67f792eac5c1d7 Mon Sep 17 00:00:00 2001 From: Georg Sieber Date: Fri, 5 Jun 2015 21:39:17 +0200 Subject: [PATCH 3/3] more formatting fixes --- i3pystatus/dpms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3pystatus/dpms.py b/i3pystatus/dpms.py index f571f3b..644fed8 100644 --- a/i3pystatus/dpms.py +++ b/i3pystatus/dpms.py @@ -6,10 +6,10 @@ class DPMS(IntervalModule): """ Shows and toggles status of DPMS which prevents screen from blanking. - .. rubric:: Available formatters * `{status}` — the current status of DPMS + @author Georg Sieber """