From b58336c621b95dcc10259f159047cb03e1dab472 Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Thu, 5 Aug 2021 09:42:23 +0200 Subject: [PATCH] ignore exit code for pamixer --- src/Monitors/Volume.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Monitors/Volume.hs b/src/Monitors/Volume.hs index 1fe5175..cf11e52 100644 --- a/src/Monitors/Volume.hs +++ b/src/Monitors/Volume.hs @@ -76,15 +76,20 @@ parseMixerInfo = fmap fmtMixer . matchRegex regex fmtData :: MixerData -> String fmtData = (separator ++ ) . getStatus +readProcessIgnoreCode :: FilePath -> [String] -> String -> IO String +readProcessIgnoreCode cmd args stdin = do + (_,out,_) <- readProcessWithExitCode cmd args stdin + return out + getMute :: String -> IO Bool -getMute cmd = parseMute <$> readProcess cmd ["--get-mute"] "" +getMute cmd = parseMute <$> readProcessIgnoreCode cmd ["--get-mute"] "" where parseMute "true" = True parseMute "false" = False parseMute _ = False getVol :: String -> IO Int -getVol cmd = parseVol <$> readProcess cmd ["--get-volume"] "" +getVol cmd = parseVol <$> readProcessIgnoreCode cmd ["--get-volume"] "" where parseVol x = case readMaybe x of (Just vol) -> vol Nothing -> 0