summaryrefslogtreecommitdiffhomepage
path: root/Plugins
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-15 01:02:38 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-15 01:02:38 +0100
commit6fadf3e159c371f00ccd6261a9f01fc81fad375e (patch)
treeca843f54daf74a981d3b536bd2761145f6bceac6 /Plugins
parentdf8768ae3ad3a3f7cc701fb0efa8c86ee8b76b34 (diff)
downloadxmobar-6fadf3e159c371f00ccd6261a9f01fc81fad375e.tar.gz
xmobar-6fadf3e159c371f00ccd6261a9f01fc81fad375e.tar.bz2
Top.hs: bug fix
We weren't guarding for the case of time lapses between updates being zero, which can be the case if we come back from sleep or the clock is externally modified.
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/Monitors/Top.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/Plugins/Monitors/Top.hs b/Plugins/Monitors/Top.hs
index 30476ac..7246183 100644
--- a/Plugins/Monitors/Top.hs
+++ b/Plugins/Monitors/Top.hs
@@ -133,8 +133,10 @@ topProcesses tref scale = do
c1 <- getCurrentTime
atomicModifyIORef tref $ \(t0, c0) ->
let scx = realToFrac (diffUTCTime c1 c0) * scale / 100
+ -- c0 and c1 can be equal, for instance, if we come back from sleep
+ !scx' = if scx > 0 then scx else (scale / 100)
ts = M.elems $ combineTimeInfos t0 t1
- nts = map (\(nm, t) -> (nm, min 100 (t / scx))) ts
+ nts = map (\(nm, t) -> (nm, min 100 (t / scx'))) ts
in ((t1, c1), (len, sortTop nts, sortTop mis))
showTimeInfo :: TimeInfo -> Monitor [String]