1
0
Fork 0

Improve taskwarrior notifications

This commit is contained in:
Malte Brandy 2020-01-19 19:55:01 +01:00
parent a276483383
commit a53cd9c5b0
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
2 changed files with 29 additions and 6 deletions

View file

@ -36,6 +36,7 @@
];
imports = [
"DBus.Notify"
"DBus.Client (clientErrorMessage)"
"System.IO"
"Data.Aeson"
"Control.Monad"
@ -64,8 +65,11 @@
String description <- HM.lookup "description" task2
pure (description, printMap diff)
Control.Monad.forM_ description $ \(d,b) -> do
client <- connectSession
notify client blankNote { summary = [i|Modified task #{d}|], body = Just $ Text b, expiry = Milliseconds 15000 }
client <- try connectSession
either
(BS.hPut stderr . encodeUtf8 . clientErrorMessage)
(\c -> void $ notify c blankNote { summary = [i|Modified task #{d}|], body = Just $ Text b, expiry = Milliseconds 15000 })
client
BS.hPut stdout input2
'';
on-add = writeHaskellScript {
@ -78,9 +82,12 @@
let description = do
Object task <- decode $ toLazy input :: Maybe Value
pure . printMap . fmap That $ task
Control.Monad.forM_ description $ \d -> do
client <- connectSession
notify client blankNote { summary = "New Task", body = Just $ Text d, expiry = Milliseconds 15000 }
whenJust description $ \d -> do
client <- try connectSession
either
(BS.hPut stderr . encodeUtf8 . clientErrorMessage)
(\c -> void $ notify c blankNote { summary = "New Task", body = Just $ Text d, expiry = Milliseconds 15000 })
client
BS.hPut stdout input
'';
in {
@ -92,6 +99,22 @@
target = ".task/hooks/on-modify.notification";
source = "${on-modify}/bin/on-modify";
};
"add-kassandra-notification" = {
target = ".task/hooks/on-add.kassandra-notification";
executable = true;
text = ''
#!${pkgs.bash}/bin/bash
tee >(nc 127.0.0.1 6545)
'';
};
"modify-kassandra-notification" = {
target = ".task/hooks/on-modify.kassandra-notification";
executable = true;
text = ''
#!${pkgs.bash}/bin/bash
tail -n 1 | tee >(nc 127.0.0.1 6545)
'';
};
};
programs.taskwarrior = let cfg = config.m-0.private.taskwarrior;
in {

View file

@ -67,7 +67,7 @@ rec {
import qualified Data.ByteString as BS
import qualified Data.Text as Text
import System.Environment (getArgs)
import Control.Exception (bracket)
import Control.Exception (bracket, try)
import Data.String.Interpolate (i)
${builtins.concatStringsSep "\n" (map (x: "import ${x}") imports)}