From fa5443124c7aded9698e7683eca1e5c31a550ed4 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 18 Dec 2011 03:17:38 +0100 Subject: New -d (decimal digits) monitor option (issue #58) --- src/Plugins/Monitors/Batt.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Plugins/Monitors/Batt.hs') diff --git a/src/Plugins/Monitors/Batt.hs b/src/Plugins/Monitors/Batt.hs index 24f5263..4445e7a 100644 --- a/src/Plugins/Monitors/Batt.hs +++ b/src/Plugins/Monitors/Batt.hs @@ -151,17 +151,18 @@ runBatt' bfs args = do opts <- io $ parseOpts args c <- io $ readBatteries opts =<< mapM batteryFiles bfs suffix <- getConfigValue useSuffix + d <- getConfigValue decDigits case c of Result x w t s -> do l <- fmtPercent x - parseTemplate (l ++ s:[fmtTime $ floor t, fmtWatts w opts suffix]) + parseTemplate (l ++ s:[fmtTime $ floor t, fmtWatts w opts suffix d]) NA -> return "N/A" where fmtPercent :: Float -> Monitor [String] fmtPercent x = do p <- showPercentWithColors x b <- showPercentBar (100 * x) x return [b, p] - fmtWatts x o s = color x o $ showDigits 1 x ++ (if s then "W" else "") + fmtWatts x o s d = color x o $ showDigits d x ++ (if s then "W" else "") fmtTime :: Integer -> String fmtTime x = hours ++ ":" ++ if length minutes == 2 then minutes else '0' : minutes @@ -170,6 +171,6 @@ runBatt' bfs args = do maybeColor Nothing str = str maybeColor (Just c) str = "" ++ str ++ "" color x o | x >= 0 = maybeColor (posColor o) - | x >= highThreshold o = maybeColor (highWColor o) - | x >= lowThreshold o = maybeColor (mediumWColor o) + | -x >= highThreshold o = maybeColor (highWColor o) + | -x >= lowThreshold o = maybeColor (mediumWColor o) | otherwise = maybeColor (lowWColor o) -- cgit v1.2.3