From f10f07c9f1a9519e7eb2b8d937c455b47f4c73ae Mon Sep 17 00:00:00 2001 From: Robin McCorkell Date: Sun, 15 Jan 2017 15:06:05 +0000 Subject: [PATCH] taskwarrior: Add reset_next_task callback Callback resets display to most urgent task after any switching by other callbacks. Installed by default on left click. --- i3pystatus/taskwarrior.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/i3pystatus/taskwarrior.py b/i3pystatus/taskwarrior.py index dc3c229..72c4e0f 100644 --- a/i3pystatus/taskwarrior.py +++ b/i3pystatus/taskwarrior.py @@ -8,11 +8,18 @@ class Taskwarrior(IntervalModule): Check Taskwarrior for pending tasks Requires `json` - Formaters: + .. rubric:: Available formatters (uses :ref:`formatp`) - * `{ready}` — contains number of tasks returned by ready_filter - * `{urgent}` — contains number of tasks returned by urgent_filter + * `{ready}` — contains number of tasks returned by `ready_filter` + * `{urgent}` — contains number of tasks returned by `urgent_filter` * `{next}` — contains the description of next task + + .. rubric:: Available callbacks + + * ``get_next_task`` — Display the next most urgent task. + * ``get_prev_task`` — Display the previous most urgent task. + * ``reset_next_task`` — Display the most urgent task, resetting any \ + switching by other callbacks. """ format = 'Task: {next}' @@ -30,6 +37,7 @@ class Taskwarrior(IntervalModule): on_upscroll = "get_prev_task" on_downscroll = "get_next_task" on_rightclick = 'mark_task_as_done' + on_leftclick = "reset_next_task" settings = ( ('format', 'format string'), @@ -40,6 +48,10 @@ class Taskwarrior(IntervalModule): ('color_ready', '#78EAF2') ) + def reset_next_task(self): + self.next_id = 0 + self.next_task = self.current_tasks[self.next_id] + def get_next_task(self): self.next_id = (self.next_id + 1) % len(self.current_tasks) self.next_task = self.current_tasks[self.next_id]