From 24a52ffb02b068135d736006fecccfe955099da7 Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Thu, 5 Aug 2021 09:54:59 +0200 Subject: [PATCH] clean newline in mute output --- src/Monitors/Volume.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Monitors/Volume.hs b/src/Monitors/Volume.hs index cf11e52..0b719a7 100644 --- a/src/Monitors/Volume.hs +++ b/src/Monitors/Volume.hs @@ -81,8 +81,14 @@ readProcessIgnoreCode cmd args stdin = do (_,out,_) <- readProcessWithExitCode cmd args stdin return out +firstWord :: String -> String +firstWord = getFirst . words + where + getFirst (x:_) = x + getFirst [] = "" + getMute :: String -> IO Bool -getMute cmd = parseMute <$> readProcessIgnoreCode cmd ["--get-mute"] "" +getMute cmd = parseMute . firstWord <$> readProcessIgnoreCode cmd ["--get-mute"] "" where parseMute "true" = True parseMute "false" = False