summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Plugins/Monitors/Alsa.hs
diff options
context:
space:
mode:
authorslotThe <soliditsallgood@tuta.io>2020-01-04 21:20:56 +0100
committerjao <jao@gnu.org>2020-01-04 21:21:40 +0000
commit940be3bb32ed1f11c46ede98d51516998b17e128 (patch)
tree6d0c942c10efc64514dd419f746f631aec19c935 /src/Xmobar/Plugins/Monitors/Alsa.hs
parent2ec513d2e193998958ad5bf4a5f7280f595792e9 (diff)
downloadxmobar-940be3bb32ed1f11c46ede98d51516998b17e128.tar.gz
xmobar-940be3bb32ed1f11c46ede98d51516998b17e128.tar.bz2
Replace parseOpts with a generic function
Diffstat (limited to 'src/Xmobar/Plugins/Monitors/Alsa.hs')
-rw-r--r--src/Xmobar/Plugins/Monitors/Alsa.hs13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Alsa.hs b/src/Xmobar/Plugins/Monitors/Alsa.hs
index 00f7353..dfc7329 100644
--- a/src/Xmobar/Plugins/Monitors/Alsa.hs
+++ b/src/Xmobar/Plugins/Monitors/Alsa.hs
@@ -57,17 +57,12 @@ options =
where
modifyVolumeOpts f o = o { aoVolumeOpts = f (aoVolumeOpts o) }
-parseOpts :: [String] -> IO AlsaOpts
-parseOpts argv =
- case getOpt Permute options argv of
- (o, _, []) -> return $ foldr id defaultOpts o
- (_, _, errs) -> ioError . userError $ concat errs
-
+-- | Drop generic Monitor args first, then apply 'parseOptsWith' in order to
+-- parse everything.
parseOptsIncludingMonitorArgs :: [String] -> IO AlsaOpts
parseOptsIncludingMonitorArgs args =
- -- Drop generic Monitor args first
case getOpt Permute [] args of
- (_, args', _) -> parseOpts args'
+ (_, args', _) -> parseOptsWith options defaultOpts args'
startAlsaPlugin :: String -> String -> [String] -> (String -> IO ()) -> IO ()
startAlsaPlugin mixerName controlName args cb = do
@@ -80,7 +75,7 @@ startAlsaPlugin mixerName controlName args cb = do
-- it would have to inline 'runMBD', 'doArgs' and 'parseOpts' to see
-- it, which probably isn't going to happen with the default
-- optimization settings).
- opts2 <- io $ parseOpts args2
+ opts2 <- io $ parseOptsWith options defaultOpts args2
Volume.runVolumeWith (aoVolumeOpts opts2) mixerName controlName
withMonitorWaiter mixerName (aoAlsaCtlPath opts) cb $ \wait_ ->