moved to pamixer
parent
b9e38a1ce1
commit
e7d15f9718
|
@ -5,6 +5,7 @@ import Data.Maybe
|
||||||
import System.Process
|
import System.Process
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
import Text.Regex
|
import Text.Regex
|
||||||
|
import Text.Read
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
import Monitors.Common
|
import Monitors.Common
|
||||||
|
@ -72,15 +73,27 @@ parseMixerInfo = fmap fmtMixer . matchRegex regex
|
||||||
vol = read volume
|
vol = read volume
|
||||||
in MixerData { mute = mute, vol = vol }
|
in MixerData { mute = mute, vol = vol }
|
||||||
|
|
||||||
parseAmixerStdout :: String -> [MixerData]
|
fmtData :: MixerData -> String
|
||||||
parseAmixerStdout = nub . mapMaybe parseMixerInfo . lines
|
fmtData = (separator ++ ) . getStatus
|
||||||
|
|
||||||
fmtData :: [MixerData] -> String
|
getMute :: IO Bool
|
||||||
fmtData = (separator ++ ) . intercalate separator . map getStatus
|
getMute = parseMute <$> readProcess "/nix/store/ambq4n07zlax0lwz0v1yph85cph1sssk-pamixer-1.4/bin/pamixer" ["--get-mute"] ""
|
||||||
|
where
|
||||||
|
parseMute "true" = True
|
||||||
|
parseMute "false" = False
|
||||||
|
parseMute _ = False
|
||||||
|
|
||||||
runAmixer :: String -> IO String
|
getVol :: IO Int
|
||||||
runAmixer mixer = readProcess "amixer" ["get", "-c", "0", mixer] ""
|
getVol = parseVol <$> readProcess "pamixer" ["--get-volume"] ""
|
||||||
|
where
|
||||||
|
parseVol x = case readMaybe x of (Just vol) -> vol
|
||||||
|
Nothing -> 0
|
||||||
|
|
||||||
|
getInfo :: IO MixerData
|
||||||
|
getInfo = do
|
||||||
|
mute <- getMute
|
||||||
|
vol <- getVol
|
||||||
|
return $ MixerData { mute = mute, vol = vol }
|
||||||
|
|
||||||
queryVolume :: IO String
|
queryVolume :: IO String
|
||||||
queryVolume = fmtData . parseAmixerStdout <$> runAmixer mixer
|
queryVolume = fmtData <$> getInfo
|
||||||
|
|
Loading…
Reference in New Issue