From bb54a114c287852344a2a43a7d905349b78dd2a9 Mon Sep 17 00:00:00 2001 From: Anish L Date: Mon, 23 May 2022 00:54:04 +1000 Subject: [PATCH] working task note --- profiles/core/default.nix | 1 + users/profiles/desktop/bin/task-note.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/profiles/core/default.nix b/profiles/core/default.nix index 2e1f9d5c..88d626a4 100644 --- a/profiles/core/default.nix +++ b/profiles/core/default.nix @@ -31,6 +31,7 @@ in environment.systemPackages = with pkgs; [ pinentry_gnome + cached-nix-shell ]; services.devmon.enable = true; diff --git a/users/profiles/desktop/bin/task-note.py b/users/profiles/desktop/bin/task-note.py index a3a02caa..990fc7d9 100755 --- a/users/profiles/desktop/bin/task-note.py +++ b/users/profiles/desktop/bin/task-note.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#! /usr/bin/env cached-nix-shell +#! nix-shell -i python3 -p python3 """Manage Taskwarrior notes""" @@ -33,11 +34,15 @@ def write_note(task_id: int): if not os.path.exists(notes_file): logging.info("Adding description to empty notes file") task_description = os.popen(f"task _get {task_id}.description").read() + task_project = os.popen(f"task _get {task_id}.project").read().strip("\n") + task_tags = os.popen(f"task _get {task_id}.tags").read().split(",") + if len(task_tags): + task_tags = ":".join(task_tags).strip("\n") + ":" time = datetime.datetime.now().strftime("%y-%m-%d %H:%M") with open(notes_file, "w") as f: - f.write(f"%title: {task_description}\n") - f.write(":task:\n") + f.write(f"%title: {task_description}") + f.write(f":task:{task_project}:{task_tags if len(task_tags) else ''}\n") f.write(f"%date: {time}\n\n") f.flush()