summaryrefslogtreecommitdiffstats
path: root/py3status
diff options
context:
space:
mode:
authorDominik <frimldom@gmail.com>2015-06-25 13:38:28 +0200
committerDominik <frimldom@gmail.com>2015-06-25 13:38:28 +0200
commitac718e7b771302ae6c0c9408ad47333f21919bab (patch)
tree3e4cece9755b90297b9637e43a063c54cc6e3834 /py3status
parentc4535a4d42eadf35e4d3945b197beb6319bbd356 (diff)
Adding external_script and static_string modules and mentioning them in readme
Diffstat (limited to 'py3status')
-rw-r--r--py3status/modules/README.md26
-rw-r--r--py3status/modules/external_script.py56
-rw-r--r--py3status/modules/static_string.py39
3 files changed, 121 insertions, 0 deletions
diff --git a/py3status/modules/README.md b/py3status/modules/README.md
index 2b62105..45d52b4 100644
--- a/py3status/modules/README.md
+++ b/py3status/modules/README.md
@@ -471,4 +471,30 @@ Available modules:
@author ultrabug
---
+static_string Display static text
+
+ Display static text given by "text" parameter
+
+ Configuration parameters:
+ - text : text that should be printed
+ - separator : whether the separator is shown or not (True or False)
+ - color : color of printed text
+ - on_click : read goo.gl/u10n0x
+
+ @author frimdo ztracenastopa@centrum.cz
+ ---
+external_script Display output of given script
+
+ Display output of any executable script set by script_path
+ Pay attention. The output must be one liner, or will break your i3status
+ The script should not have any parameters, but it could work
+
+ Configuration parameters:
+ - cache_timeout : how often we refresh this module in seconds
+ - script_path : script you want to show output of (compulsory)
+ - color : color of printed text
+ - on_click : read goo.gl/u10n0x
+
+ @author frimdo ztracenastopa@centrum.cz
+ ---
```
diff --git a/py3status/modules/external_script.py b/py3status/modules/external_script.py
new file mode 100644
index 0000000..9488c79
--- /dev/null
+++ b/py3status/modules/external_script.py
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+"""
+Display output of given script
+
+Display output of any executable script set by script_path
+Pay attention. The output must be one liner, or will break your i3status
+The script should not have any parameters, but it could work
+
+Configuration parameters:
+ - cache_timeout : how often we refresh this module in seconds
+ - script_path : script you want to show output of (compulsory)
+ - color : color of printed text
+ - on_click : read goo.gl/u10n0x
+
+@author frimdo ztracenastopa@centrum.cz
+"""
+
+import subprocess
+from time import time
+
+
+class Py3status:
+ cache_timeout = 15
+ color = None
+ script_path = None
+
+ def external_script(self, i3s_output_list, i3s_config):
+
+ if self.script_path:
+
+ return_value = subprocess.check_output(self.script_path, shell=True, universal_newlines=True)
+ response = {
+ 'cached_until': time() + self.cache_timeout,
+ 'full_text': return_value.rstrip(),
+ 'color': self.color
+ }
+
+ else:
+ response = {
+ 'cached_until': time() + self.cache_timeout,
+ 'full_text': ""
+ }
+
+ return response
+
+if __name__ == "__main__":
+ from time import sleep
+ x = Py3status()
+ config = {
+ 'color_good': '#00FF00',
+ 'color_bad': '#FF0000',
+ }
+ while True:
+ print(x.external_script([], config))
+ sleep(x.cache_timeout)
+
diff --git a/py3status/modules/static_string.py b/py3status/modules/static_string.py
new file mode 100644
index 0000000..d525238
--- /dev/null
+++ b/py3status/modules/static_string.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+"""
+Display static text
+
+Display static text given by "text" parameter
+
+Configuration parameters:
+ - text : text that should be printed
+ - separator : whether the separator is shown or not (True or False)
+ - color : color of printed text
+ - on_click : read goo.gl/u10n0x
+
+@author frimdo ztracenastopa@centrum.cz
+"""
+
+class Py3status:
+ color = None
+ text = ""
+ separator = True
+
+ def static_string(self, i3s_output_list, i3s_config):
+
+ response = {
+ 'full_text': self.text,
+ 'color': self.color,
+ 'separator': self.separator
+ }
+
+ return response
+
+if __name__ == "__main__":
+ from time import sleep
+ x = Py3status()
+ config = {
+ 'color_good': '#00FF00',
+ 'color_bad': '#FF0000',
+ }
+ print(x.static_string([], config))
+