From e367b7882de2b9fea8ed716e10120944026b60eb Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sat, 19 Feb 2022 05:29:06 +0100 Subject: [PATCH] improve taskwarrior pushover --- .../modules/services/taskwarrior-pushover.nix | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/taskwarrior-pushover.nix b/nixos/modules/services/taskwarrior-pushover.nix index ba39345..1cffa6a 100644 --- a/nixos/modules/services/taskwarrior-pushover.nix +++ b/nixos/modules/services/taskwarrior-pushover.nix @@ -46,6 +46,16 @@ in server = mkOption { type = str; }; + tagLimitInTitle = mkOption { + type = int; + default = 10; + description = "tag limit for title, TagsInTitle must be enabled for this to work"; + }; + tagsInTitle = mkOption { + type = bool; + default = true; + description = "should tags be used for titles? (see tagLimitInTitle to limit the amount of tags)"; + }; }; config = mkIf cfg.enable { @@ -77,6 +87,11 @@ in rc.taskd.server=${cfg.server} \ "$@" ''; + # tags as title + title = + if (cfg.tagsInTitle && (cfg.tagLimitInTitle > 0)) + then ''(.tags | if . == null or . == [] then "taskwarrior" else [limit(${toString cfg.tagLimitInTitle};.[])] | join(",") end)'' + else ''"taskwarrior"''; in '' if [ -d /var/lib/${name}/${cfg.dataDir} ] @@ -92,10 +107,11 @@ in | ${pkgs.jq}/bin/jq -r '.[] | @base64' | while read entry do echo $entry | base64 --decode | \ - ${pkgs.jq}/bin/jq '{ + ${pkgs.jq}/bin/jq ' + { "token": "'`cat ${cfg.pushoverApiTokenFile}`'", "user": "'`cat ${cfg.pushoverUserKeyFile}`'", - "titel": "taskwarrior", + title: ${title}, message: .description }' \ | ${pkgs.curl}/bin/curl -sS -X POST -H 'Content-Type: application/json' -d @- \