summaryrefslogtreecommitdiff
path: root/custom
diff options
context:
space:
mode:
Diffstat (limited to 'custom')
-rw-r--r--custom/notify-user.nix11
1 files changed, 6 insertions, 5 deletions
diff --git a/custom/notify-user.nix b/custom/notify-user.nix
index d3e69bcd..808d1615 100644
--- a/custom/notify-user.nix
+++ b/custom/notify-user.nix
@@ -10,24 +10,25 @@ stdenv.mkDerivation {
10 import System.FilePath.Glob (glob) 10 import System.FilePath.Glob (glob)
11 import System.Environment (setEnv, getArgs) 11 import System.Environment (setEnv, getArgs)
12 import System.Process (callProcess) 12 import System.Process (callProcess)
13 import System.Posix.Escape (escape)
14 13
15 import Data.List (isPrefixOf, dropWhileEnd) 14 import Data.List (isPrefixOf, dropWhileEnd)
16 import Data.Char (isSpace) 15 import Data.Char (isSpace)
17 16
18 import Control.Monad (forM_) 17 import Control.Monad (forM_)
19 18
20 main = do 19 main = do
21 envFiles <- glob "/home/${user}/.dbus/session-bus/*" 20 envFiles <- glob "/home/${user}/.dbus/session-bus/*"
22 forM_ envFiles $ \envFile -> do 21 forM_ envFiles $ \envFile -> do
23 sessionAddr <- tail . snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> readFile envFile 22 sessionAddr <- tail . snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> readFile envFile
24 setEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr 23 setEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr
25 callProcess "${libnotify}/bin/notify-send" =<< (++) <$> getArgs <*> (pure . escape . dropWhileEnd isSpace <$> getContents) 24 callProcess "${libnotify}/bin/notify-send" =<< (++) <$> getArgs <*> (pure . concatMap escape . dropWhileEnd isSpace <$> getContents)
26 25 where
26 escape '\\' = "\\\\"
27 escape x = pure x
27 ''; }; 28 ''; };
28 phases = [ "buildPhase" "installPhase" ]; 29 phases = [ "buildPhase" "installPhase" ];
29 buildPhase = '' 30 buildPhase = ''
30 ${ghcWithPackages (p: with p; [ Glob process posix-escape ])}/bin/ghc -odir . -hidir . $src -o notify-${user} 31 ${ghcWithPackages (p: with p; [ Glob process ])}/bin/ghc -odir . -hidir . $src -o notify-${user}
31 ''; 32 '';
32 installPhase = '' 33 installPhase = ''
33 mkdir -p $out/bin 34 mkdir -p $out/bin