From d9f15faaf6a61380a51c99349932718a181513f4 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Sat, 3 May 2014 19:36:39 +0200 Subject: rename examples folder to the modules and prepare for installation --- modules/dpms.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 modules/dpms.py (limited to 'modules/dpms.py') diff --git a/modules/dpms.py b/modules/dpms.py new file mode 100644 index 0000000..783c53c --- /dev/null +++ b/modules/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 + """ + 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") -- cgit v1.3