summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Main.hs3
-rw-r--r--src/Xmobar.hs24
2 files changed, 13 insertions, 14 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 0d4c113..e8efd61 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -57,8 +57,7 @@ main = do
cls <- mapM (parseTemplate conf) (splitTemplate conf)
vars <- mapM (mapM startCommand) cls
(r,w) <- createWin d fs conf
- sig <- setupSignalHandler
- eventLoop (XConf d r w fs conf) vars sig
+ eventLoop (XConf d r w fs conf) vars
-- | Splits the template in its parts
splitTemplate :: Config -> [String]
diff --git a/src/Xmobar.hs b/src/Xmobar.hs
index abf6ab3..c5613a6 100644
--- a/src/Xmobar.hs
+++ b/src/Xmobar.hs
@@ -18,7 +18,6 @@ module Xmobar
-- $main
X , XConf (..), runX
, eventLoop
- , setupSignalHandler
-- * Program Execution
-- $command
, startCommand
@@ -79,26 +78,27 @@ instance Exception WakeUp
data SignalType = Wakeup | Reposition | ChangeScreen
-- | The event loop
-eventLoop :: XConf -> [[(Maybe ThreadId, TVar String)]] -> MVar SignalType -> IO ()
-eventLoop xcfg@(XConf d _ w fs _) vs signal = do
+eventLoop :: XConf -> [[(Maybe ThreadId, TVar String)]] -> IO ()
+eventLoop xcfg@(XConf d _ w fs _) vs = do
tv <- atomically $ newTVar []
- _ <- forkIO (checker tv [] `catch` \(SomeException _) -> putStrLn "Oh Noez checker" >> return ())
- _ <- forkOS (eventer `catch` \(SomeException _) -> putStrLn "Oh Noez eventer" >>return ())
- go tv xcfg
+ sig <- setupSignalHandler
+ _ <- forkIO (checker tv [] sig `catch` \(SomeException _) -> putStrLn "Oh Noez checker" >> return ())
+ _ <- forkOS (eventer sig `catch` \(SomeException _) -> putStrLn "Oh Noez eventer" >>return ())
+ go tv xcfg sig
where
-- interrupt the drawing thread every time a var is updated
- checker tvar ov = do
+ checker tvar ov signal = do
nval <- atomically $ do
nv <- mapM concatV vs
guard (nv /= ov)
writeTVar tvar nv
return nv
putMVar signal Wakeup
- checker tvar nval
+ checker tvar nval signal
concatV = fmap concat . mapM (readTVar . snd)
- eventer =
+ eventer signal =
alloca $ \ptrEventBase ->
alloca $ \ptrErrorBase ->
allocaXEvent $ \e -> do
@@ -123,12 +123,12 @@ eventLoop xcfg@(XConf d _ w fs _) vs signal = do
-- Continuously wait for a timer interrupt or an expose event
- go tv xc@(XConf _ _ _ _ cfg) = do
+ go tv xc@(XConf _ _ _ _ cfg) signal = do
typ <- takeMVar signal
case typ of
Wakeup -> do
runX xc (updateWin tv)
- go tv xc
+ go tv xc signal
Reposition -> reposWindow cfg
ChangeScreen ->
case position cfg of
@@ -143,7 +143,7 @@ eventLoop xcfg@(XConf d _ w fs _) vs signal = do
where
reposWindow rcfg = do
r' <- repositionWin d w fs rcfg
- go tv (XConf d r' w fs rcfg)
+ go tv (XConf d r' w fs rcfg) signal
-- | Signal handling
setupSignalHandler :: IO (MVar SignalType)