ignore exit code for pamixer

Ricard Illa 2021-08-05 09:42:23 +02:00
parent 37e8aa3554
commit b58336c621
No known key found for this signature in database
GPG Key ID: F69A672B72E54902
1 changed files with 7 additions and 2 deletions

View File

@ -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