hXmixer 0.2.5.0 → 0.3.0.0
raw patch · 2 files changed
+20/−14 lines, 2 files
Files
- hXmixer.cabal +3/−4
- src/MixerQuery.hs +17/−10
hXmixer.cabal view
@@ -1,8 +1,7 @@ name: hXmixer -version: 0.2.5.0 -synopsis: A Gtk mixer application for FreeBSD -description: A Gtk mixer application for FreeBSD -homepage: http://colinrmitchell.endoftheinternet.org/ +version: 0.3.0.0 +synopsis: A Gtk mixer GUI application for FreeBSD +description: A Gtk mixer GUI application for FreeBSD license: BSD3 license-file: LICENSE author: Colin Mitchell
src/MixerQuery.hs view
@@ -15,13 +15,17 @@ -- | Gets all available mixer devices on this system. mixerDevices :: IO [FilePath] mixerDevices = - getDirectoryContents "/dev" >>= return . ("Default" : ) . map ((++) "/dev/") . sort . filter (isInfixOf "mixer") + fmap + (("Default" :) . map ((++) "/dev/") . sort . filter (isInfixOf "mixer")) + $ getDirectoryContents "/dev" -- | Gets the channels from a mixer device. mixerChannels :: FilePath -> IO [(String, (Int, Int))] -mixerChannels mixer = do - (_, stdout, _, _) <- runInteractiveCommand $ command mixer - hGetContents stdout >>= return . parseMixerLines . lines +mixerChannels mixer = + fmap + (parseMixerLines . lines) + ((runInteractiveCommand $ command mixer) + >>= (\(_, stdout, _, _) -> hGetContents stdout)) where command "Default" = "mixer" command mixer' = "mixer -f " ++ mixer' @@ -36,9 +40,12 @@ -- | Sets the volume of a channel. setVol :: String -> String -> Int -> Int -> IO () -setVol "Default" channel left right = - setVolCmd ["mixer", channel, (show left) ++ ":" ++ (show right)] -setVol mixer channel left right = - setVolCmd ["mixer", "-f", mixer, channel, (show left) ++ ":" ++ (show right)] - -setVolCmd cmd = (runInteractiveCommand $ unwords cmd) >>= \_ -> return () +setVol mixer channel left right + | mixer == "Default" + = (runInteractiveCommand + (unwords ["mixer", channel, (show left) ++ ":" ++ (show right)])) + >> return () + | otherwise + = (runInteractiveCommand + (unwords ["mixer", "-f", mixer, channel, (show left) ++ ":" ++ (show right)])) + >> return ()