From e662431a5cef5eacd68b987610f2d434fa687844 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Sat, 22 Feb 2020 22:06:48 +0000 Subject: Timer coalescing: gracefully uncoalesce slow timers The first implementation assumed all timers (monitors) are fast and frequent (which happens to be the case in my configuration). This meant that a single on-line weather monitor could block the entire xmobar instance for a long time due to the refresh pausing (meant to reduce power consumption). This commit attempts to fix that by limiting the refresh pause time and using the old periodic sleep method for these slow timers (monitors). --- src/Xmobar/Run/Exec.hs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/Xmobar/Run') diff --git a/src/Xmobar/Run/Exec.hs b/src/Xmobar/Run/Exec.hs index ad68232..d8cf81a 100644 --- a/src/Xmobar/Run/Exec.hs +++ b/src/Xmobar/Run/Exec.hs @@ -21,20 +21,10 @@ module Xmobar.Run.Exec (Exec (..), tenthSeconds, doEveryTenthSeconds) where import Prelude import Data.Char -import Control.Concurrent -import Xmobar.App.Timer (doEveryTenthSeconds) +import Xmobar.App.Timer (doEveryTenthSeconds, tenthSeconds) import Xmobar.System.Signal --- | Work around to the Int max bound: since threadDelay takes an Int, it --- is not possible to set a thread delay grater than about 45 minutes. --- With a little recursion we solve the problem. -tenthSeconds :: Int -> IO () -tenthSeconds s | s >= x = do threadDelay (x * 100000) - tenthSeconds (s - x) - | otherwise = threadDelay (s * 100000) - where x = (maxBound :: Int) `div` 100000 - class Show e => Exec e where alias :: e -> String alias e = takeWhile (not . isSpace) $ show e -- cgit v1.2.3