diff options
author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-07-21 21:07:32 +0200 |
---|---|---|
committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-07-21 21:07:32 +0200 |
commit | 9f6e296ad8ab3546aebb5da4b99a770546603a13 (patch) | |
tree | 6ee5b8c21a4e8b0a3bb49c97268c86f13ba7e5a0 | |
parent | 9e619f1e9c0ed50ad36a3790782eab3d18dbd827 (diff) | |
download | nixos-9f6e296ad8ab3546aebb5da4b99a770546603a13.tar nixos-9f6e296ad8ab3546aebb5da4b99a770546603a13.tar.gz nixos-9f6e296ad8ab3546aebb5da4b99a770546603a13.tar.bz2 nixos-9f6e296ad8ab3546aebb5da4b99a770546603a13.tar.xz nixos-9f6e296ad8ab3546aebb5da4b99a770546603a13.zip |
revert to more complicated version of notify-user
-rw-r--r-- | custom/notify-user.nix | 29 | ||||
-rw-r--r-- | hel.nix | 9 |
2 files changed, 30 insertions, 8 deletions
diff --git a/custom/notify-user.nix b/custom/notify-user.nix new file mode 100644 index 00000000..ae8ea56c --- /dev/null +++ b/custom/notify-user.nix | |||
@@ -0,0 +1,29 @@ | |||
1 | { stdenv, writeTextFile | ||
2 | , ghcWithPackages | ||
3 | , user ? "gkleen" | ||
4 | , libnotify | ||
5 | }: | ||
6 | |||
7 | stdenv.mkDerivation { | ||
8 | name = ''notify-${user}''; | ||
9 | src = writeTextFile { name = ''notify-${user}.hs''; text = '' | ||
10 | import Control.Shell | ||
11 | import System.FilePath.Glob (glob) | ||
12 | |||
13 | import Data.List (isPrefixOf) | ||
14 | |||
15 | main = shell_ $ do | ||
16 | (envFile:_) <- liftIO $ glob "/home/${user}/.dbus/session-bus/*-0" | ||
17 | sessionAddr <- snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> input envFile | ||
18 | env <- getShellEnv | ||
19 | withEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr $ run "${libnotify}/bin/notify-send" cmdline | ||
20 | ''; }; | ||
21 | phases = [ "buildPhase" "installPhase" ]; | ||
22 | buildPhase = '' | ||
23 | ${ghcWithPackages (p: with p; [ shellmate Glob ])}/bin/ghc -odir . -hidir . $src -o notify-${user} | ||
24 | ''; | ||
25 | installPhase = '' | ||
26 | mkdir -p $out/bin | ||
27 | install -m 755 notify-${user} $out/bin | ||
28 | ''; | ||
29 | } | ||
@@ -254,14 +254,7 @@ | |||
254 | program = "notify-gkleen"; | 254 | program = "notify-gkleen"; |
255 | setgid = true; | 255 | setgid = true; |
256 | setuid = true; | 256 | setuid = true; |
257 | source = pkgs.writeScript "notify-gkleen" '' | 257 | source = pkgs.callPackage ./custom/notify-user.nix { inherit (pkgs.haskellPackages) ghcWithPackages; }; |
258 | #!${pkgs.zsh}/bin/zsh | ||
259 | |||
260 | trap "exit 0" EXIT | ||
261 | |||
262 | DBUS_ADDRESS=$(grep "DBUS_SESSION_BUS_ADDRESS=" /home/gkleen/.dbus/session-bus/${"*"} | cut -d "=" -f 2-) | ||
263 | exec env DBUS_SESSION_BUS_ADDRESS=''${DBUS_ADDRESS} ${pkgs.libnotify}/bin/notify-send $@ | ||
264 | ''; | ||
265 | } | 258 | } |
266 | ]; | 259 | ]; |
267 | }; | 260 | }; |