summaryrefslogtreecommitdiffhomepage
path: root/src
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
parent5aae9bf15e38d5a9ba8ffa3cca7fd545f4ffe1e1 (diff)
downloadxmobar-f7e4b2be56f20862191e05fa4509473a1bc92f5a.tar.gz
xmobar-f7e4b2be56f20862191e05fa4509473a1bc92f5a.tar.bz2
Wee refactoring
Diffstat (limited to 'src')
-rw-r--r--src/lib/Xmobar/Commands.hs19
-rw-r--r--src/lib/Xmobar/Plugins/DateZone.hs1
-rw-r--r--src/lib/Xmobar/Plugins/MarqueePipeReader.hs3
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Common.hs2
-rw-r--r--src/lib/Xmobar/Utils.hs13
5 files changed, 18 insertions, 20 deletions
diff --git a/src/lib/Xmobar/Commands.hs b/src/lib/Xmobar/Commands.hs
index 93a9590..5917bb8 100644
--- a/src/lib/Xmobar/Commands.hs
+++ b/src/lib/Xmobar/Commands.hs
@@ -17,14 +17,9 @@
--
-----------------------------------------------------------------------------
-module Xmobar.Commands
- ( Command (..)
- , Exec (..)
- , tenthSeconds
- ) where
+module Xmobar.Commands (Command (..), Exec (..)) where
import Prelude
-import Control.Concurrent
import Control.Exception (handle, SomeException(..))
import Data.Char
import System.Process
@@ -32,7 +27,7 @@ import System.Exit
import System.IO (hClose)
import Xmobar.System.Signal
-import Xmobar.Utils (hGetLineSafe)
+import Xmobar.Utils (hGetLineSafe, tenthSeconds)
class Show e => Exec e where
alias :: e -> String
@@ -75,13 +70,3 @@ instance Exec Command where
closeHandles
cb str
_ -> closeHandles >> cb msg
-
-
--- | 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
diff --git a/src/lib/Xmobar/Plugins/DateZone.hs b/src/lib/Xmobar/Plugins/DateZone.hs
index 5dad871..f3207c8 100644
--- a/src/lib/Xmobar/Plugins/DateZone.hs
+++ b/src/lib/Xmobar/Plugins/DateZone.hs
@@ -23,6 +23,7 @@
module Xmobar.Plugins.DateZone (DateZone(..)) where
import Xmobar.Commands
+import Xmobar.Utils(tenthSeconds)
#ifdef DATEZONE
import Control.Concurrent.STM
diff --git a/src/lib/Xmobar/Plugins/MarqueePipeReader.hs b/src/lib/Xmobar/Plugins/MarqueePipeReader.hs
index 32c6997..7d28d24 100644
--- a/src/lib/Xmobar/Plugins/MarqueePipeReader.hs
+++ b/src/lib/Xmobar/Plugins/MarqueePipeReader.hs
@@ -17,7 +17,8 @@ module Xmobar.Plugins.MarqueePipeReader where
import System.IO (openFile, IOMode(ReadWriteMode), Handle)
import Xmobar.System.Environment
import Xmobar.Utils(hGetLineSafe)
-import Xmobar.Commands(tenthSeconds, Exec(alias, start))
+import Xmobar.Commands(Exec(alias, start))
+import Xmobar.Utils(tenthSeconds)
import System.Posix.Files (getFileStatus, isNamedPipe)
import Control.Concurrent(forkIO, threadDelay)
import Control.Concurrent.STM (TChan, atomically, writeTChan, tryReadTChan, newTChan)
diff --git a/src/lib/Xmobar/Plugins/Monitors/Common.hs b/src/lib/Xmobar/Plugins/Monitors/Common.hs
index d024336..f683874 100644
--- a/src/lib/Xmobar/Plugins/Monitors/Common.hs
+++ b/src/lib/Xmobar/Plugins/Monitors/Common.hs
@@ -76,7 +76,7 @@ import Text.ParserCombinators.Parsec
import System.Console.GetOpt
import Control.Exception (SomeException,handle)
-import Xmobar.Commands
+import Xmobar.Utils
-- $monitor
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