diff options
author | Thomas Tuegel <ttuegel@gmail.com> | 2011-01-13 13:19:59 -0600 |
---|---|---|
committer | Thomas Tuegel <ttuegel@gmail.com> | 2011-01-13 13:19:59 -0600 |
commit | 01b569b0b39d678e52009e590061902d392ca25e (patch) | |
tree | d05662388aac202959b58bc50df7e0f25f5bb717 /src/Plugins/Monitors | |
parent | 0d9c121385d428d0b9ba82aa956ca5123e395f09 (diff) | |
download | xmobar-01b569b0b39d678e52009e590061902d392ca25e.tar.gz xmobar-01b569b0b39d678e52009e590061902d392ca25e.tar.bz2 |
Added more graceful failure strategies to volume monitor.
Diffstat (limited to 'src/Plugins/Monitors')
-rw-r--r-- | src/Plugins/Monitors/Volume.hs | 18 |
1 files changed, 12 insertions, 6 deletions
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 ] |