From aee4dad69764015aa1578f43d44dd72382f11de6 Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 18 Aug 2015 02:58:27 +0200 Subject: Batt: protecting against charge_now > charge_full (yes, it's happening on an xps with kernel 4.1.5) --- src/Plugins/Monitors/Batt.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Plugins/Monitors/Batt.hs b/src/Plugins/Monitors/Batt.hs index f7b31e4..61961cb 100644 --- a/src/Plugins/Monitors/Batt.hs +++ b/src/Plugins/Monitors/Batt.hs @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Batt --- Copyright : (c) 2010, 2011, 2012, 2013 Jose A Ortega +-- Copyright : (c) 2010, 2011, 2012, 2013, 2015 Jose A Ortega -- (c) 2010 Andrea Rossato, Petr Rockai -- License : BSD-style (see LICENSE) -- @@ -160,11 +160,10 @@ readBatteries opts bfs = ft = sum (map full bats) left = if ft > 0 then sum (map now bats) / ft else 0 watts = sign * sum (map power bats) - idle = watts == 0 - time = if idle then 0 else sum $ map time' bats - mwatts = if idle then 1 else sign * watts + time = if watts == 0 then 0 else max 0 (sum $ map time' bats) + mwatts = if watts == 0 then 1 else sign * watts time' b = (if ac then full b - now b else now b) / mwatts - acst | idle = Idle + acst | time == 0 = Idle | ac = Charging | otherwise = Discharging return $ if isNaN left then NA else Result left watts time acst -- cgit v1.2.3