diff options
| author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-10-02 16:37:44 +0200 |
|---|---|---|
| committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-10-02 16:37:44 +0200 |
| commit | 95fefb100bdd9d4c4c70f532a68ed08b559676b8 (patch) | |
| tree | 75d0e8f396ee0007ef81a4c9f94526293c968a51 | |
| parent | 1a985428485065f419126f52fd05902043f9e5be (diff) | |
| download | nixos-95fefb100bdd9d4c4c70f532a68ed08b559676b8.tar nixos-95fefb100bdd9d4c4c70f532a68ed08b559676b8.tar.gz nixos-95fefb100bdd9d4c4c70f532a68ed08b559676b8.tar.bz2 nixos-95fefb100bdd9d4c4c70f532a68ed08b559676b8.tar.xz nixos-95fefb100bdd9d4c4c70f532a68ed08b559676b8.zip | |
heuristic to strip quotes
| -rw-r--r-- | custom/notify-user.nix | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/custom/notify-user.nix b/custom/notify-user.nix index 58beebf7..ddf78db0 100644 --- a/custom/notify-user.nix +++ b/custom/notify-user.nix | |||
| @@ -14,7 +14,7 @@ stdenv.mkDerivation { | |||
| 14 | import System.Process (spawnProcess, waitForProcess) | 14 | import System.Process (spawnProcess, waitForProcess) |
| 15 | import System.Exit (exitWith, ExitCode(..)) | 15 | import System.Exit (exitWith, ExitCode(..)) |
| 16 | 16 | ||
| 17 | import Data.List (isPrefixOf, dropWhile, dropWhileEnd) | 17 | import Data.List (isPrefixOf, dropWhile, dropWhileEnd, init) |
| 18 | import Data.Char (isSpace) | 18 | import Data.Char (isSpace) |
| 19 | 19 | ||
| 20 | import Control.Monad (forM_, void) | 20 | import Control.Monad (forM_, void) |
| @@ -25,7 +25,7 @@ stdenv.mkDerivation { | |||
| 25 | main = do | 25 | main = do |
| 26 | envFiles <- glob "/home/${user}/.dbus/session-bus/*" | 26 | envFiles <- glob "/home/${user}/.dbus/session-bus/*" |
| 27 | forM_ envFiles $ \envFile -> do | 27 | forM_ envFiles $ \envFile -> do |
| 28 | sessionAddr <- tail . snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> readFile envFile | 28 | sessionAddr <- unQuote . tail . snd . break (== '=') . head . filter ("DBUS_SESSION_BUS_ADDRESS=" `isPrefixOf`) . lines <$> readFile envFile |
| 29 | setEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr | 29 | setEnv "DBUS_SESSION_BUS_ADDRESS" sessionAddr |
| 30 | lines <- lines <$> getContents | 30 | lines <- lines <$> getContents |
| 31 | case lines of | 31 | case lines of |
| @@ -34,6 +34,9 @@ stdenv.mkDerivation { | |||
| 34 | Notify.display_ $ Notify.appName "notify-${user}" <> Notify.summary summary <> Notify.body contents | 34 | Notify.display_ $ Notify.appName "notify-${user}" <> Notify.summary summary <> Notify.body contents |
| 35 | where | 35 | where |
| 36 | trim = dropWhileEnd isSpace . dropWhile isSpace | 36 | trim = dropWhileEnd isSpace . dropWhile isSpace |
| 37 | unQuote ('\'':xs) = init xs | ||
| 38 | unQuote ('"':xs) = init xs | ||
| 39 | unQuote xs = xs | ||
| 37 | ''; }; | 40 | ''; }; |
| 38 | phases = [ "buildPhase" "installPhase" ]; | 41 | phases = [ "buildPhase" "installPhase" ]; |
| 39 | buildPhase = '' | 42 | buildPhase = '' |
