diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2014-01-12 18:19:42 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2014-01-12 18:50:05 +0100 |
| commit | 6d2be07500cac4b71155bbcc0d4727616554e01b (patch) | |
| tree | d459df8a865a41ebfd27c58b3619fb92593b6378 | |
| parent | 28763201e039bbbfb63a95072707c314e34e4088 (diff) | |
new module dpms.py allowing activation and deactivation of DPMS thx to André Doser
| -rw-r--r-- | examples/dpms.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/examples/dpms.py b/examples/dpms.py new file mode 100644 index 0000000..783c53c --- /dev/null +++ b/examples/dpms.py @@ -0,0 +1,44 @@ +from os import system + + +class Py3status: + """ + This module allows activation and deactivation + of DPMS (Display Power Management Signaling) + by clicking on 'DPMS' in the status bar. + + Written and contributed by @tasse: + Andre Doser <dosera AT tf.uni-freiburg.de> + """ + def __init__(self): + """ + Detect current state on start. + """ + self.run = system('xset -q | grep -iq "DPMS is enabled"') == 0 + + def dpms(self, i3status_output_json, i3status_config): + """ + Display a colorful state of DPMS. + """ + result = { + 'full_text': 'DPMS', + 'name': 'dpms' + } + if self.run: + result['color'] = i3status_config['color_good'] + else: + result['color'] = i3status_config['color_bad'] + return (0, result) + + def on_click(self, json, i3status_config, event): + """ + Enable/Disable DPMS on left click. + """ + if event['button'] == 1: + if self.run: + self.run = False + system("xset -dpms") + else: + self.run = True + system("xset +dpms") + system("killall -USR1 py3status") |
