From ed8801ddec7a2a046231b34e1f84ad39fb26af48 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 21 Jul 2016 22:01:28 +0200 Subject: custom escaping --- custom/notify-user.nix | 11 ++++++----- 1 file 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 { import System.FilePath.Glob (glob) import System.Environment (setEnv, getArgs) import System.Process (callProcess) - import System.Posix.Escape (escape) import Data.List (isPrefixOf, dropWhileEnd) import Data.Char (isSpace) import Control.Monad (forM_) - + main = do envFiles <- glob "/home/${user}/.dbus/session-bus/*" forM_ envFiles $ \envFile -> do sessionAddr <- tail . snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> readFile envFile setEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr - callProcess "${libnotify}/bin/notify-send" =<< (++) <$> getArgs <*> (pure . escape . dropWhileEnd isSpace <$> getContents) - + callProcess "${libnotify}/bin/notify-send" =<< (++) <$> getArgs <*> (pure . concatMap escape . dropWhileEnd isSpace <$> getContents) + where + escape '\\' = "\\\\" + escape x = pure x ''; }; phases = [ "buildPhase" "installPhase" ]; buildPhase = '' - ${ghcWithPackages (p: with p; [ Glob process posix-escape ])}/bin/ghc -odir . -hidir . $src -o notify-${user} + ${ghcWithPackages (p: with p; [ Glob process ])}/bin/ghc -odir . -hidir . $src -o notify-${user} ''; installPhase = '' mkdir -p $out/bin -- cgit v1.2.3