From 24c84e47177b6ebbe3df99db53220def6c0951ec Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 25 Nov 2018 23:43:41 +0000 Subject: Xmobar.System.Utils, Xmobar.X11.Events --- src/Xmobar/Run/Commands.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/Xmobar/Run/Commands.hs') diff --git a/src/Xmobar/Run/Commands.hs b/src/Xmobar/Run/Commands.hs index 198edee..2aac344 100644 --- a/src/Xmobar/Run/Commands.hs +++ b/src/Xmobar/Run/Commands.hs @@ -17,7 +17,7 @@ -- ----------------------------------------------------------------------------- -module Xmobar.Run.Commands (Command (..), Exec (..)) where +module Xmobar.Run.Commands (Command (..), Exec (..), tenthSeconds) where import Prelude import Control.Exception (handle, SomeException(..)) @@ -25,9 +25,19 @@ import Data.Char import System.Process import System.Exit import System.IO (hClose) +import Control.Concurrent import Xmobar.System.Signal -import Xmobar.Utils (hGetLineSafe, tenthSeconds) +import Xmobar.System.Utils (hGetLineSafe) + +-- | 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 -- cgit v1.2.3