Improve taskwarrior notifications
This commit is contained in:
parent
a276483383
commit
a53cd9c5b0
|
@ -36,6 +36,7 @@
|
||||||
];
|
];
|
||||||
imports = [
|
imports = [
|
||||||
"DBus.Notify"
|
"DBus.Notify"
|
||||||
|
"DBus.Client (clientErrorMessage)"
|
||||||
"System.IO"
|
"System.IO"
|
||||||
"Data.Aeson"
|
"Data.Aeson"
|
||||||
"Control.Monad"
|
"Control.Monad"
|
||||||
|
@ -64,8 +65,11 @@
|
||||||
String description <- HM.lookup "description" task2
|
String description <- HM.lookup "description" task2
|
||||||
pure (description, printMap diff)
|
pure (description, printMap diff)
|
||||||
Control.Monad.forM_ description $ \(d,b) -> do
|
Control.Monad.forM_ description $ \(d,b) -> do
|
||||||
client <- connectSession
|
client <- try connectSession
|
||||||
notify client blankNote { summary = [i|Modified task #{d}|], body = Just $ Text b, expiry = Milliseconds 15000 }
|
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
|
BS.hPut stdout input2
|
||||||
'';
|
'';
|
||||||
on-add = writeHaskellScript {
|
on-add = writeHaskellScript {
|
||||||
|
@ -78,9 +82,12 @@
|
||||||
let description = do
|
let description = do
|
||||||
Object task <- decode $ toLazy input :: Maybe Value
|
Object task <- decode $ toLazy input :: Maybe Value
|
||||||
pure . printMap . fmap That $ task
|
pure . printMap . fmap That $ task
|
||||||
Control.Monad.forM_ description $ \d -> do
|
whenJust description $ \d -> do
|
||||||
client <- connectSession
|
client <- try connectSession
|
||||||
notify client blankNote { summary = "New Task", body = Just $ Text d, expiry = Milliseconds 15000 }
|
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
|
BS.hPut stdout input
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
|
@ -92,6 +99,22 @@
|
||||||
target = ".task/hooks/on-modify.notification";
|
target = ".task/hooks/on-modify.notification";
|
||||||
source = "${on-modify}/bin/on-modify";
|
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;
|
programs.taskwarrior = let cfg = config.m-0.private.taskwarrior;
|
||||||
in {
|
in {
|
||||||
|
|
|
@ -67,7 +67,7 @@ rec {
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
import System.Environment (getArgs)
|
import System.Environment (getArgs)
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket, try)
|
||||||
import Data.String.Interpolate (i)
|
import Data.String.Interpolate (i)
|
||||||
${builtins.concatStringsSep "\n" (map (x: "import ${x}") imports)}
|
${builtins.concatStringsSep "\n" (map (x: "import ${x}") imports)}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue