summaryrefslogtreecommitdiffstats
path: root/py3status
diff options
context:
space:
mode:
authorUltrabug <ultrabug@ultrabug.net>2015-07-24 13:56:25 +0200
committerUltrabug <ultrabug@ultrabug.net>2015-07-24 13:56:25 +0200
commitbff7750c59118c7b32e943a3119baefab980b17e (patch)
treef309f5e6d10a16eceeb27e6dbfc3cede6df288a5 /py3status
parent74db2ed0c93cd90eb3394fffe20a4a369bfda694 (diff)
parent822c6086a878c57047c3f6de79dddb677b1e6cf0 (diff)
Merge pull request #109 from shrimpza/master
dpms module: add format string support wrt issue #98 by @shrimpza
Diffstat (limited to 'py3status')
-rw-r--r--py3status/modules/dpms.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/py3status/modules/dpms.py b/py3status/modules/dpms.py
index ecbc3a7..6a5d881 100644
--- a/py3status/modules/dpms.py
+++ b/py3status/modules/dpms.py
@@ -6,6 +6,10 @@ This module allows activation and deactivation
of DPMS (Display Power Management Signaling)
by clicking on 'DPMS' in the status bar.
+Configuration parameters:
+ - format_off: string to display when DPMS is disabled
+ - format_on: string to display when DPMS is enabled
+
@author Andre Doser <dosera AT tf.uni-freiburg.de>
"""
@@ -15,6 +19,10 @@ from os import system
class Py3status:
"""
"""
+ # available configuration parameters
+ format_off = "DPMS"
+ format_on = "DPMS"
+
def dpms(self, i3s_output_list, i3s_config):
"""
Display a colorful state of DPMS.
@@ -23,13 +31,10 @@ class Py3status:
self.run = system('xset -q | grep -iq "DPMS is enabled"') == 0
response = {
- 'full_text': 'DPMS'
+ '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):
@@ -43,3 +48,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)