summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--custom/notify-user.nix12
1 files changed, 10 insertions, 2 deletions
diff --git a/custom/notify-user.nix b/custom/notify-user.nix
index e5f001f3..6345f142 100644
--- a/custom/notify-user.nix
+++ b/custom/notify-user.nix
@@ -7,11 +7,14 @@
7stdenv.mkDerivation { 7stdenv.mkDerivation {
8 name = ''notify-${user}''; 8 name = ''notify-${user}'';
9 src = writeTextFile { name = ''notify-${user}.hs''; text = '' 9 src = writeTextFile { name = ''notify-${user}.hs''; text = ''
10 {-# LANGUAGE ViewPatterns #-}
11
10 import System.FilePath.Glob (glob) 12 import System.FilePath.Glob (glob)
11 import System.Environment (setEnv, getArgs) 13 import System.Environment (setEnv, getArgs)
12 import System.Process (callProcess) 14 import System.Process (callProcess)
15 import System.Exit (exitWith, ExitSuccess)
13 16
14 import Data.List (isPrefixOf, dropWhileEnd) 17 import Data.List (isPrefixOf, dropWhile, dropWhileEnd)
15 import Data.Char (isSpace) 18 import Data.Char (isSpace)
16 19
17 import Control.Monad (forM_) 20 import Control.Monad (forM_)
@@ -21,7 +24,12 @@ stdenv.mkDerivation {
21 forM_ envFiles $ \envFile -> do 24 forM_ envFiles $ \envFile -> do
22 sessionAddr <- tail . snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> readFile envFile 25 sessionAddr <- tail . snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> readFile envFile
23 setEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr 26 setEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr
24 callProcess "${libnotify}/bin/notify-send" =<< (++) <$> getArgs <*> (pure . dropWhileEnd isSpace <$> getContents) 27 lines <- lines <$> getContents
28 case lines of
29 [] -> exitWith ExitSuccess
30 ((trim -> summary):(trim . unlines -> contents)) -> callProcess "${libnotify}/bin/notify-send" =<< (++) <$> getArgs <*> [summary, contents]
31 where
32 trim = dropWhileEnd isSpace . dropWhile isSpace
25 ''; }; 33 ''; };
26 phases = [ "buildPhase" "installPhase" ]; 34 phases = [ "buildPhase" "installPhase" ];
27 buildPhase = '' 35 buildPhase = ''