From 0d3021eb601dadfa10fae30f108108894086c82c Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 28 Jan 2022 05:11:09 +0000 Subject: Basic text output, without colors, working --- src/Xmobar/App/Main.hs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/Xmobar/App/Main.hs') diff --git a/src/Xmobar/App/Main.hs b/src/Xmobar/App/Main.hs index b67012d..ead3249 100644 --- a/src/Xmobar/App/Main.hs +++ b/src/Xmobar/App/Main.hs @@ -42,14 +42,15 @@ import Xmobar.X11.Types import Xmobar.X11.Text import Xmobar.X11.Window import Xmobar.App.Opts (recompileFlag, verboseFlag, getOpts, doOpts) -import Xmobar.App.EventLoop (startLoop) import Xmobar.App.CommandThreads (startCommand, newRefreshLock, refreshLock) +import Xmobar.App.EventLoop (startLoop) +import Xmobar.App.TextEventLoop (startTextLoop) import Xmobar.App.Compile (recompile, trace) import Xmobar.App.Config import Xmobar.App.Timer (withTimer) -xmobar :: Config -> IO () -xmobar conf = withDeferSignals $ do +xXmobar :: Config -> IO () +xXmobar conf = withDeferSignals $ do initThreads d <- openDisplay "" fs <- initFont d (font conf) @@ -70,6 +71,24 @@ xmobar conf = withDeferSignals $ do ts = textOffsets conf ++ replicate (length fl) (-1) startLoop (XConf d r w (fs :| fl) (to :| ts) ic conf) sig refLock vars +textXmobar :: Config -> IO () +textXmobar conf = withDeferSignals $ do + initThreads + cls <- mapM (parseTemplate (commands conf) (sepChar conf)) + (splitTemplate (alignSep conf) (template conf)) + let confSig = unSignalChan (signal conf) + sig <- maybe newEmptyTMVarIO pure confSig + unless (isJust confSig) $ setupSignalHandler sig + refLock <- newRefreshLock + withTimer (refreshLock refLock) $ + bracket (mapM (mapM $ startCommand sig) cls) + cleanupThreads + $ \vars -> do + startTextLoop conf sig refLock vars + +xmobar :: Config -> IO () +xmobar cfg = if textOutput cfg then textXmobar cfg else xXmobar cfg + configFromArgs :: Config -> IO Config configFromArgs cfg = getArgs >>= getOpts >>= doOpts cfg . fst -- cgit v1.2.3