summaryrefslogtreecommitdiffstats
path: root/py3status/modules/taskwarrior.py
diff options
context:
space:
mode:
authorUltrabug <ultrabug@ultrabug.net>2015-08-03 15:42:46 +0200
committerUltrabug <ultrabug@ultrabug.net>2015-08-03 15:42:46 +0200
commit997ffaa72e4bfa6e598723908c88952988ca69be (patch)
tree71a822c462cf42aa8bcd3a3f176f8bfa99a50960 /py3status/modules/taskwarrior.py
parent1249f655de1cdfc1c9b7bc869604ab49dd3f58a4 (diff)
parent8e6dac5a7135476c8f9865340559af9047dc2246 (diff)
Merge pull request #108 from jazmit/master
new taskwarrior module by @jazmit
Diffstat (limited to 'py3status/modules/taskwarrior.py')
-rw-r--r--py3status/modules/taskwarrior.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/py3status/modules/taskwarrior.py b/py3status/modules/taskwarrior.py
new file mode 100644
index 0000000..75faa8f
--- /dev/null
+++ b/py3status/modules/taskwarrior.py
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+"""
+Display currently active (started) taskwarrior tasks.
+
+Configuration parameters:
+ - cache_timeout : how often we refresh this module in seconds
+
+Requires
+ - task
+
+@author James Smith http://jazmit.github.io/
+@license BSD
+"""
+
+# import your useful libs here
+from time import time
+from subprocess import check_output
+import shlex
+import json
+
+
+class Py3status:
+ cache_timeout = 5
+
+ def taskWarrior(self, i3s_output_list, i3s_config):
+ command = "task start.before:tomorrow status:pending export"
+ taskwarrior_output = check_output(shlex.split(command))
+ tasks_json = json.loads("[" + taskwarrior_output + "]")
+
+ def describeTask(taskObj):
+ return str(taskObj['id']) + " " + taskObj['description']
+
+ result = ', '.join(map(describeTask, tasks_json))
+ response = {
+ 'cached_until': time() + self.cache_timeout,
+ 'full_text': result
+ }
+ 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)