summaryrefslogtreecommitdiffhomepage
path: root/XMobar.hs
diff options
context:
space:
mode:
Diffstat (limited to 'XMobar.hs')
-rw-r--r--XMobar.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/XMobar.hs b/XMobar.hs
index a68f0b0..ff3a59b 100644
--- a/XMobar.hs
+++ b/XMobar.hs
@@ -261,8 +261,12 @@ initColor dpy c = (color_pixel . fst) `liftM` allocNamedColor dpy colormap c
io :: IO a -> Xbar a
io = liftIO
+-- | work arount the 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 =
- threadDelay n
- where n | (maxBound :: Int) `div` 100000 <= s = (maxBound :: Int)
- | otherwise = s * 100000
+tenthSeconds s | s >= x = do threadDelay y
+ tenthSeconds (x - s)
+ | otherwise = threadDelay (s * 100000)
+ where y = (maxBound :: Int)
+ x = y `div` 100000