summaryrefslogtreecommitdiffhomepage
path: root/src/lib/Xmobar/Utils.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2018-11-25 06:28:21 +0000
committerjao <jao@gnu.org>2018-11-25 06:28:21 +0000
commitf7e4b2be56f20862191e05fa4509473a1bc92f5a (patch)
treefa12f893d52c4dccbca305503fd1efc6ecb4ccb5 /src/lib/Xmobar/Utils.hs
parent5aae9bf15e38d5a9ba8ffa3cca7fd545f4ffe1e1 (diff)
downloadxmobar-f7e4b2be56f20862191e05fa4509473a1bc92f5a.tar.gz
xmobar-f7e4b2be56f20862191e05fa4509473a1bc92f5a.tar.bz2
Wee refactoring
Diffstat (limited to 'src/lib/Xmobar/Utils.hs')
-rw-r--r--src/lib/Xmobar/Utils.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/lib/Xmobar/Utils.hs b/src/lib/Xmobar/Utils.hs
index 7e79514..a2da606 100644
--- a/src/lib/Xmobar/Utils.hs
+++ b/src/lib/Xmobar/Utils.hs
@@ -17,7 +17,8 @@
------------------------------------------------------------------------------
-module Xmobar.Utils (expandHome, changeLoop, hGetLineSafe, nextEvent')
+module Xmobar.Utils
+ (expandHome, changeLoop, hGetLineSafe, nextEvent', tenthSeconds)
where
import Control.Monad
@@ -69,3 +70,13 @@ nextEvent' d p = do
nextEvent' d p
where
fd = connectionNumber d
+
+
+-- | 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