Compare commits

..

No commits in common. "165195cd964969c744120997850954c9371690a4" and "37e8aa3554f77d95300838349e262598212d16bf" have entirely different histories.

2 changed files with 3 additions and 11 deletions

View File

@ -9,18 +9,15 @@ import Monitors.Net (queryNet)
import Monitors.Volume (queryVolume) import Monitors.Volume (queryVolume)
usage :: IO String usage :: IO String
usage = printf "%s bat (acpi_command) | vol (pamixer_command) | net (nmcli_command) | date" <$> getProgName usage = printf "%s bat | vol | net | date" <$> getProgName
main :: IO () main :: IO ()
main = do main = do
args <- getArgs args <- getArgs
output <- case args of output <- case args of
[ "bat", cmd ] -> queryBattery cmd [ "bat", cmd ] -> queryBattery cmd
[ "bat" ] -> queryBattery "acpi"
[ "vol", cmd ] -> queryVolume cmd [ "vol", cmd ] -> queryVolume cmd
[ "vol" ] -> queryVolume "pamixer"
[ "net", cmd ] -> queryNet cmd [ "net", cmd ] -> queryNet cmd
[ "net" ] -> queryNet "nmcli"
[ "date" ] -> queryDate True [ "date" ] -> queryDate True
[ "date-min" ] -> queryDate False [ "date-min" ] -> queryDate False
_ -> usage _ -> usage

View File

@ -76,20 +76,15 @@ parseMixerInfo = fmap fmtMixer . matchRegex regex
fmtData :: MixerData -> String fmtData :: MixerData -> String
fmtData = (separator ++ ) . getStatus 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 :: String -> IO Bool
getMute cmd = parseMute <$> readProcessIgnoreCode cmd ["--get-mute"] "" getMute cmd = parseMute <$> readProcess cmd ["--get-mute"] ""
where where
parseMute "true" = True parseMute "true" = True
parseMute "false" = False parseMute "false" = False
parseMute _ = False parseMute _ = False
getVol :: String -> IO Int getVol :: String -> IO Int
getVol cmd = parseVol <$> readProcessIgnoreCode cmd ["--get-volume"] "" getVol cmd = parseVol <$> readProcess cmd ["--get-volume"] ""
where where
parseVol x = case readMaybe x of (Just vol) -> vol parseVol x = case readMaybe x of (Just vol) -> vol
Nothing -> 0 Nothing -> 0