From 6dc290a5313acf8d190fc1467c3a5003f9f87ba0 Mon Sep 17 00:00:00 2001 From: Kenneth Watson Date: Mon, 20 Jul 2015 20:48:41 +0200 Subject: add format string support for dpms module, and add some options --- py3status/modules/dpms.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'py3status/modules') diff --git a/py3status/modules/dpms.py b/py3status/modules/dpms.py index ecbc3a7..262c82b 100644 --- a/py3status/modules/dpms.py +++ b/py3status/modules/dpms.py @@ -6,6 +6,14 @@ This module allows activation and deactivation of DPMS (Display Power Management Signaling) by clicking on 'DPMS' in the status bar. +Configuration parameters: + - format: output format string + - status_off: string to display when DPMS is enabled + - status_on: string to display when DPMS is disabled + +Format of status string placeholders: + {status} - DPMS status (defined by status_on/off parameters) + @author Andre Doser """ @@ -15,6 +23,11 @@ from os import system class Py3status: """ """ + # available configuration parameters + format = "DPMS" + status_off = "Off" + status_on = "On" + def dpms(self, i3s_output_list, i3s_config): """ Display a colorful state of DPMS. @@ -23,13 +36,16 @@ class Py3status: self.run = system('xset -q | grep -iq "DPMS is enabled"') == 0 response = { - 'full_text': 'DPMS' + 'full_text': self.format.format( + status = self.status_on if self.run else self.status_off + ) } if self.run: response['color'] = i3s_config['color_good'] else: response['color'] = i3s_config['color_bad'] + return response def on_click(self, i3s_output_list, i3s_config, event): @@ -43,3 +59,18 @@ class Py3status: else: self.run = True system("xset +dpms;xset s on") + +if __name__ == "__main__": + """ + Test this module by calling it directly. + """ + from time import sleep + x = Py3status() + config = { + 'color_bad': '#FF0000', + 'color_good': '#00FF00', + } + + while True: + print(x.dpms([], config)) + sleep(1) -- cgit v1.3 From 580156b5835d131d9b9d060d550a85e6d3e0beb4 Mon Sep 17 00:00:00 2001 From: Kenneth Watson Date: Tue, 21 Jul 2015 16:48:03 +0200 Subject: address comment raised in #109, now uses separate format strings for on/off, rather than status strings --- py3status/modules/dpms.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'py3status/modules') diff --git a/py3status/modules/dpms.py b/py3status/modules/dpms.py index 262c82b..f939111 100644 --- a/py3status/modules/dpms.py +++ b/py3status/modules/dpms.py @@ -7,12 +7,8 @@ of DPMS (Display Power Management Signaling) by clicking on 'DPMS' in the status bar. Configuration parameters: - - format: output format string - - status_off: string to display when DPMS is enabled - - status_on: string to display when DPMS is disabled - -Format of status string placeholders: - {status} - DPMS status (defined by status_on/off parameters) + - format_off: string to display when DPMS is enabled + - format_on: string to display when DPMS is disabled @author Andre Doser """ @@ -24,9 +20,8 @@ class Py3status: """ """ # available configuration parameters - format = "DPMS" - status_off = "Off" - status_on = "On" + format_off = "DPMS" + format_on = "DPMS" def dpms(self, i3s_output_list, i3s_config): """ @@ -36,16 +31,10 @@ class Py3status: self.run = system('xset -q | grep -iq "DPMS is enabled"') == 0 response = { - 'full_text': self.format.format( - status = self.status_on if self.run else self.status_off - ) + 'full_text': self.format_on if self.run else self.format_off, + 'color': i3s_config['color_good'] if self.run else i3s_config['color_bad'] } - if self.run: - response['color'] = i3s_config['color_good'] - else: - response['color'] = i3s_config['color_bad'] - return response def on_click(self, i3s_output_list, i3s_config, event): -- cgit v1.3 From 822c6086a878c57047c3f6de79dddb677b1e6cf0 Mon Sep 17 00:00:00 2001 From: Kenneth Watson Date: Tue, 21 Jul 2015 16:50:07 +0200 Subject: typo, my bad :( --- py3status/modules/dpms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'py3status/modules') diff --git a/py3status/modules/dpms.py b/py3status/modules/dpms.py index f939111..6a5d881 100644 --- a/py3status/modules/dpms.py +++ b/py3status/modules/dpms.py @@ -7,8 +7,8 @@ of DPMS (Display Power Management Signaling) by clicking on 'DPMS' in the status bar. Configuration parameters: - - format_off: string to display when DPMS is enabled - - format_on: string to display when DPMS is disabled + - format_off: string to display when DPMS is disabled + - format_on: string to display when DPMS is enabled @author Andre Doser """ -- cgit v1.3