Add Habiticatasks
This commit is contained in:
parent
729edc9af0
commit
76eb041fc2
|
@ -35,6 +35,29 @@
|
|||
${pkgs.coreutils}/bin/tail -n 1 | ${pkgs.coreutils}/bin/tee >(${pkgs.netcat}/bin/nc 127.0.0.1 6545)
|
||||
'';
|
||||
};
|
||||
"modify-done-habitica-points" = {
|
||||
target = ".task/hooks/on-modify.habitica-points";
|
||||
executable = true;
|
||||
source = "${pkgs.writeHaskellScript
|
||||
{
|
||||
name = "habitica-points";
|
||||
bins = [ pkgs.curl pkgs.jq pkgs.libnotify ];
|
||||
imports = [ "Data.Aeson" ];
|
||||
} ''
|
||||
|
||||
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))
|
||||
when (oldStatus /= "done" && newStatus == "completed") $ do
|
||||
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
|
||||
putTextLn oldTask
|
||||
''}/bin/habitica-points";
|
||||
};
|
||||
};
|
||||
programs.taskwarrior = {
|
||||
enable = true;
|
||||
|
@ -69,3 +92,4 @@
|
|||
'';
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ in
|
|||
libraries = builtins.attrValues pkgs.myHaskellScriptPackages;
|
||||
} ''
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
|
2
private
2
private
|
@ -1 +1 @@
|
|||
Subproject commit 12317ad7803d716fc9b8b2e2c01a92774410b7e4
|
||||
Subproject commit 102e6914fbdfd3ea069bcce521a4142b2a995372
|
Loading…
Reference in a new issue