diff options
author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-07-22 14:10:37 +0200 |
---|---|---|
committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-07-22 14:10:37 +0200 |
commit | fca62a1a38a1ae94501d7b70d7fde8fc4d58f84a (patch) | |
tree | af67478cfed922951668a30ebdccda29bf1642f5 /custom/notify-user.nix | |
parent | 22585cdf070a6ce1831cff1a11e0a92884132277 (diff) | |
download | nixos-fca62a1a38a1ae94501d7b70d7fde8fc4d58f84a.tar nixos-fca62a1a38a1ae94501d7b70d7fde8fc4d58f84a.tar.gz nixos-fca62a1a38a1ae94501d7b70d7fde8fc4d58f84a.tar.bz2 nixos-fca62a1a38a1ae94501d7b70d7fde8fc4d58f84a.tar.xz nixos-fca62a1a38a1ae94501d7b70d7fde8fc4d58f84a.zip |
better notify-user
Diffstat (limited to 'custom/notify-user.nix')
-rw-r--r-- | custom/notify-user.nix | 12 |
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 @@ | |||
7 | stdenv.mkDerivation { | 7 | stdenv.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 = '' |