diff options
author | jao <jao@gnu.org> | 2018-11-25 23:43:41 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2018-11-25 23:43:41 +0000 |
commit | 24c84e47177b6ebbe3df99db53220def6c0951ec (patch) | |
tree | 76ab584623118b7dde610c94639d44951cf83b6e /src/Xmobar/Run/Commands.hs | |
parent | 54cf675f1299a74466950be240a708a762335d5d (diff) | |
download | xmobar-24c84e47177b6ebbe3df99db53220def6c0951ec.tar.gz xmobar-24c84e47177b6ebbe3df99db53220def6c0951ec.tar.bz2 |
Xmobar.System.Utils, Xmobar.X11.Events
Diffstat (limited to 'src/Xmobar/Run/Commands.hs')
-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 |