improve taskwarrior pushover

This commit is contained in:
Ingolf Wagner 2022-02-19 05:29:06 +01:00
parent 9a916d6a2c
commit e367b7882d
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B

View file

@ -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 @- \