From 01b569b0b39d678e52009e590061902d392ca25e Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Thu, 13 Jan 2011 13:19:59 -0600 Subject: Added more graceful failure strategies to volume monitor. --- src/Plugins/Monitors/Volume.hs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/Plugins/Monitors') diff --git a/src/Plugins/Monitors/Volume.hs b/src/Plugins/Monitors/Volume.hs index 960b5e4..380df30 100644 --- a/src/Plugins/Monitors/Volume.hs +++ b/src/Plugins/Monitors/Volume.hs @@ -93,10 +93,16 @@ runVolume mixerName controlName argv = do switchControl = fromJust $ maybe (playback $ switch control) Just (common $ switch control) (lo, hi) <- io $ getRange volumeControl - val <- liftM fromJust $ io $ getChannel FrontLeft $ value volumeControl - db <- liftM fromJust $ io $ getChannel FrontLeft $ dB volumeControl - sw <- liftM fromJust $ io $ getChannel FrontLeft $ switchControl - p <- formatVol val lo hi - d <- formatDb opts $ fromIntegral db / 100.0 - s <- formatSwitch opts sw + val <- io $ getChannel FrontLeft $ value volumeControl + db <- io $ getChannel FrontLeft $ dB volumeControl + sw <- io $ getChannel FrontLeft $ switchControl + p <- case val of + Just x -> formatVol x lo hi + Nothing -> formatVol hi lo hi + d <- case db of + Just x -> formatDb opts $ fromIntegral x / 100.0 + Nothing -> formatDb opts 0.0 + s <- case sw of + Just x -> formatSwitch opts x + Nothing -> formatSwitch opts True parseTemplate $ [ p, d, s ] -- cgit v1.2.3