external_script module: allow display full output as notification on click
@@ -10,6 +10,8 @@ code such as #FF0000 for red).
The script should not have any parameters, but it could work.
Configuration parameters:
+ button_show_notification: button to show notification with full output
+ (default None)
cache_timeout: how often we refresh this module in seconds
(default 15)
format: see placeholders below (default '{output}')
@@ -21,6 +23,7 @@ Configuration parameters:
(default False)
Format placeholders:
+ {lines} number of lines in the output
{output} output of script given by "script_path"
i3status.conf example:
@@ -49,6 +52,7 @@ class Py3status:
"""
"""
# available configuration parameters
+ button_show_notification = None
cache_timeout = 15
format = '{output}'
localize = True
@@ -64,8 +68,8 @@ class Py3status:
response = {}
response['cached_until'] = self.py3.time_in(self.cache_timeout)
try:
- output = self.py3.command_output(self.script_path, shell=True, localized=self.localize)
- output_lines = output.splitlines()
+ self.output = self.py3.command_output(self.script_path, shell=True, localized=self.localize)
+ output_lines = self.output.splitlines()
if len(output_lines) > 1:
output_color = output_lines[1]
if re.search(r'^#[0-9a-fA-F]{6}$', output_color):
@@ -97,9 +101,15 @@ class Py3status:
output = ''
response['full_text'] = self.py3.safe_format(
- self.format, {'output': output})
+ self.format, {'output': output, 'lines': len(output_lines)})
return response
+ def on_click(self, event):
+ button = event["button"]
+ if button == self.button_show_notification:
+ self.py3.notify_user(self.output)
+ self.py3.prevent_refresh()
+
if __name__ == "__main__":
"""
