diff options
-rw-r--r-- | custom/notify-user.nix | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/custom/notify-user.nix b/custom/notify-user.nix index 68e267d6..e3437ea7 100644 --- a/custom/notify-user.nix +++ b/custom/notify-user.nix | |||
@@ -8,23 +8,22 @@ 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 | import System.FilePath.Glob (glob) | 10 | import System.FilePath.Glob (glob) |
11 | import System.Directory (setCurrentDirectory) | ||
12 | import System.Environment (setEnv, getArgs) | 11 | import System.Environment (setEnv, getArgs) |
13 | import System.Process (callProcess) | 12 | import System.Process (callProcess) |
14 | 13 | ||
15 | import Data.List (isPrefixOf) | 14 | import Data.List (isPrefixOf) |
16 | 15 | ||
17 | main = do | 16 | main = do |
18 | setCurrentDirectory "/" | 17 | envFiles <- glob "/home/${user}/.dbus/session-bus/*" |
19 | (envFile:_) <- glob "/home/${user}/.dbus/session-bus/*" | 18 | forM envFiles $ \envFile -> do |
20 | sessionAddr <- snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> readFile envFile | 19 | sessionAddr <- snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> readFile envFile |
21 | setEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr | 20 | setEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr |
22 | callProcess "${libnotify}/bin/notify-send" =<< getArgs | 21 | callProcess "${libnotify}/bin/notify-send" =<< getArgs |
23 | 22 | ||
24 | ''; }; | 23 | ''; }; |
25 | phases = [ "buildPhase" "installPhase" ]; | 24 | phases = [ "buildPhase" "installPhase" ]; |
26 | buildPhase = '' | 25 | buildPhase = '' |
27 | ${ghcWithPackages (p: with p; [ Glob directory process ])}/bin/ghc -odir . -hidir . $src -o notify-${user} | 26 | ${ghcWithPackages (p: with p; [ Glob process ])}/bin/ghc -odir . -hidir . $src -o notify-${user} |
28 | ''; | 27 | ''; |
29 | installPhase = '' | 28 | installPhase = '' |
30 | mkdir -p $out/bin | 29 | mkdir -p $out/bin |