diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2011-12-18 03:17:38 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2011-12-18 03:17:38 +0100 |
commit | fa5443124c7aded9698e7683eca1e5c31a550ed4 (patch) | |
tree | 006fdebe6e83a1b4619cb8c0f9060274f41a357d /src/Plugins/Monitors/Batt.hs | |
parent | 1e43372a6112a8f07ab47be470ba68633f96741b (diff) | |
download | xmobar-fa5443124c7aded9698e7683eca1e5c31a550ed4.tar.gz xmobar-fa5443124c7aded9698e7683eca1e5c31a550ed4.tar.bz2 |
New -d (decimal digits) monitor option (issue #58)
Diffstat (limited to 'src/Plugins/Monitors/Batt.hs')
-rw-r--r-- | src/Plugins/Monitors/Batt.hs | 9 |
1 files changed, 5 insertions, 4 deletions
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 = "<fc=" ++ c ++ ">" ++ str ++ "</fc>" 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) |