diff options
| author | James <james@schoolshape.com> | 2015-07-15 23:06:21 +0100 |
|---|---|---|
| committer | James <james@schoolshape.com> | 2015-07-15 23:06:21 +0100 |
| commit | f69e9954fafeaf5983dff8c2aae4b286d12a8418 (patch) | |
| tree | 41800a7871d437a8255b6754cf25ebe885e9a74c /py3status/modules | |
| parent | f46c6a6569a96576fbaca0e6f8ec93f90b9883a7 (diff) | |
Added TaskWarrior module
Diffstat (limited to 'py3status/modules')
| -rw-r--r-- | py3status/modules/taskwarrior.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/py3status/modules/taskwarrior.py b/py3status/modules/taskwarrior.py new file mode 100644 index 0000000..a464a32 --- /dev/null +++ b/py3status/modules/taskwarrior.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +""" +Display currently active (started) taskwarrior tasks. + +Configuration parameters: + - cache_timeout : how often we refresh this module in seconds + +Requires + - jq + - awk + +@author James Smith http://jazmit.github.io/ +@license BSD +""" + +# import your useful libs here +from time import time +import subprocess + +class Py3status: + cache_timeout = 5 + + def taskWarrior(self, i3s_output_list, i3s_config): + active_task = subprocess.check_output( + """task start.before:tomorrow status:pending export \ + | awk 'BEGIN { print "["} { print $0 } END { print "]"}' \ + | jq -r 'map( (.id | tostring) + " " + .description ) | join(", ")' \ + """, + shell=True).strip() + response = { + 'cached_until': time() + self.cache_timeout, + 'full_text': active_task + } + return response + +if __name__ == "__main__": + """ + Test this module by calling it directly. + """ + from time import sleep + x = Py3status() + config = { + 'color_bad': '#FF0000', + 'color_degraded': '#FFFF00', + 'color_good': '#00FF00' + } + while True: + print(x.taskWarrior([], config)) + sleep(1) |
