diff options
Diffstat (limited to 'src/Xmobar/Run')
| -rw-r--r-- | src/Xmobar/Run/Commands.hs | 14 | 
1 files changed, 12 insertions, 2 deletions
| 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 | 
