2022-03-08 01:42:46 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
home.packages = [pkgs.taskwarrior-git];
|
2019-12-15 12:52:24 +00:00
|
|
|
services.taskwarrior-sync = {
|
|
|
|
enable = true;
|
|
|
|
frequency = "*:0/1";
|
|
|
|
};
|
2021-07-15 12:11:07 +00:00
|
|
|
systemd.user.services.watch-tasks = {
|
|
|
|
Unit.Description = "Watch tasks for changes and trigger sync";
|
|
|
|
Service = {
|
|
|
|
ExecStart = toString (
|
|
|
|
pkgs.writeShellScript "watch-vdir" ''
|
2021-07-16 07:58:42 +00:00
|
|
|
while ${pkgs.coreutils}/bin/sleep 1s; do
|
2021-07-15 12:11:07 +00:00
|
|
|
${pkgs.taskwarrior}/bin/task sync
|
|
|
|
${pkgs.inotify-tools}/bin/inotifywait -e move,create,delete,modify -r ${config.home.homeDirectory}/.task
|
|
|
|
done
|
|
|
|
''
|
|
|
|
);
|
|
|
|
};
|
2022-03-08 01:42:46 +00:00
|
|
|
Install.WantedBy = ["default.target"];
|
2021-07-15 12:11:07 +00:00
|
|
|
};
|
2020-12-26 12:21:51 +00:00
|
|
|
home.file = {
|
2020-01-19 18:55:01 +00:00
|
|
|
"add-kassandra-notification" = {
|
|
|
|
target = ".task/hooks/on-add.kassandra-notification";
|
|
|
|
executable = true;
|
|
|
|
text = ''
|
|
|
|
#!${pkgs.bash}/bin/bash
|
2020-01-19 19:16:10 +00:00
|
|
|
${pkgs.coreutils}/bin/tee >(${pkgs.netcat}/bin/nc 127.0.0.1 6545)
|
2020-01-19 18:55:01 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
"modify-kassandra-notification" = {
|
|
|
|
target = ".task/hooks/on-modify.kassandra-notification";
|
|
|
|
executable = true;
|
|
|
|
text = ''
|
|
|
|
#!${pkgs.bash}/bin/bash
|
2020-01-19 19:16:10 +00:00
|
|
|
${pkgs.coreutils}/bin/tail -n 1 | ${pkgs.coreutils}/bin/tee >(${pkgs.netcat}/bin/nc 127.0.0.1 6545)
|
2020-01-19 18:55:01 +00:00
|
|
|
'';
|
|
|
|
};
|
2022-01-27 23:35:56 +00:00
|
|
|
"modify-done-habitica-points" = {
|
|
|
|
target = ".task/hooks/on-modify.habitica-points";
|
|
|
|
executable = true;
|
2022-03-08 01:42:46 +00:00
|
|
|
source = "${
|
|
|
|
pkgs.writeHaskellScript
|
2022-01-27 23:35:56 +00:00
|
|
|
{
|
|
|
|
name = "habitica-points";
|
2022-03-08 01:42:46 +00:00
|
|
|
bins = [pkgs.curl pkgs.jq pkgs.libnotify];
|
|
|
|
imports = ["Data.Aeson"];
|
2022-01-27 23:35:56 +00:00
|
|
|
} ''
|
|
|
|
|
|
|
|
data Task = Task { status :: Text } deriving (Generic, FromJSON)
|
|
|
|
|
|
|
|
main = do
|
|
|
|
oldTask <- getLine
|
|
|
|
newTask <- getLine
|
|
|
|
let oldStatus = maybe "unknown" status (decode (encodeUtf8 oldTask))
|
|
|
|
newStatus = maybe "unknown" status (decode (encodeUtf8 newTask))
|
2022-01-27 23:53:37 +00:00
|
|
|
when (oldStatus /= "completed" && newStatus == "completed") $ do
|
2022-01-27 23:35:56 +00:00
|
|
|
result :: String <- curl "-XPOST" "-H" "x-api-user: dbd97aba-8b6b-4649-9dd4-dad284333925" "-H" "x-api-key: ${pkgs.privateValue "" "habitica-token"}" "https://habitica.com/api/v3/tasks/6e95cccd-06e1-466c-b871-643dff31423c/score/up" |> jq "-c" ".data._tmp" |> captureTrim <&> decodeUtf8
|
|
|
|
notify_send "Task Completed!" result
|
2022-01-27 23:40:18 +00:00
|
|
|
putTextLn newTask
|
2022-03-08 01:42:46 +00:00
|
|
|
''
|
|
|
|
}/bin/habitica-points";
|
2022-01-27 23:35:56 +00:00
|
|
|
};
|
2020-01-10 19:33:05 +00:00
|
|
|
};
|
2020-12-26 12:21:51 +00:00
|
|
|
programs.taskwarrior = {
|
2019-12-15 12:52:24 +00:00
|
|
|
enable = true;
|
2019-12-16 13:50:31 +00:00
|
|
|
dataLocation = "${config.home.homeDirectory}/.task";
|
2019-12-15 12:52:24 +00:00
|
|
|
config = {
|
|
|
|
taskd = {
|
2020-09-30 23:30:40 +00:00
|
|
|
certificate = pkgs.privatePath "taskwarrior/public.cert";
|
|
|
|
credentials = pkgs.privateValue "" "taskwarrior/credentials";
|
|
|
|
ca = pkgs.privatePath "taskwarrior/ca.cert";
|
|
|
|
key = pkgs.privatePath "taskwarrior/private.key";
|
2019-12-15 12:52:24 +00:00
|
|
|
server = "hera.m-0.eu:53589";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
|
|
|
alias.inbox=+PENDING -TAGGED limit:1
|
|
|
|
alias.inboxall=+PENDING -TAGGED
|
|
|
|
|
|
|
|
verbose=blank,header,footnote,label,new-id,affected,edit,special,sync
|
|
|
|
nag=
|
|
|
|
|
|
|
|
|
|
|
|
uda.partof.type=string
|
|
|
|
uda.partof.label=Parent task
|
|
|
|
uda.generated.type=string
|
|
|
|
uda.gen_name.type=string
|
|
|
|
uda.gen_name.label=Generator name
|
|
|
|
uda.gen_id.type=string
|
|
|
|
uda.gen_id.label=Generator id
|
|
|
|
uda.gen_orphan.type=string
|
|
|
|
uda.gen_orphan.label=Generated orphan behavior
|
|
|
|
uda.listposition.type=numeric
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|