From 5c6252dc55a87a42c3cd43e5ffab7e9328004f4d Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 28 Sep 2014 00:36:33 +0200 Subject: Using fromMaybe --- src/Plugins/Monitors/MPD.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Plugins/Monitors/MPD.hs b/src/Plugins/Monitors/MPD.hs index e02a747..5e02587 100644 --- a/src/Plugins/Monitors/MPD.hs +++ b/src/Plugins/Monitors/MPD.hs @@ -15,6 +15,7 @@ module Plugins.Monitors.MPD ( mpdConfig, runMPD, mpdWait, mpdReady ) where import Data.List +import Data.Maybe (fromMaybe) import Plugins.Monitors.Common import System.Console.GetOpt import qualified Network.MPD as M @@ -96,12 +97,8 @@ parseMPD (Right st) song opts = do where s = M.stState st ss = show s si = stateGlyph s opts - vol = int2str $ case M.stVolume st of - Just x -> x - Nothing -> 0 - (p, t) = case M.stTime st of - Just x -> x - Nothing -> (0, 0) + vol = int2str $ fromMaybe 0 (M.stVolume st) + (p, t) = fromMaybe (0, 0) (M.stTime st) [lap, len, remain] = map showTime [floor p, t, max 0 (t - floor p)] b = if t > 0 then realToFrac $ p / fromIntegral t else 0 plen = int2str $ M.stPlaylistLength st -- cgit v1.2.3