diff options
author | jao <jao@gnu.org> | 2022-01-28 05:11:09 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-01-29 06:42:29 +0000 |
commit | 0d3021eb601dadfa10fae30f108108894086c82c (patch) | |
tree | 887481657041ed1dad5e86d47ab61594e52654b6 /src/Xmobar/App/Main.hs | |
parent | 93da696658061e1c14fdca70b6c0f04c412b1fd8 (diff) | |
download | xmobar-0d3021eb601dadfa10fae30f108108894086c82c.tar.gz xmobar-0d3021eb601dadfa10fae30f108108894086c82c.tar.bz2 |
Basic text output, without colors, working
Diffstat (limited to 'src/Xmobar/App/Main.hs')
-rw-r--r-- | src/Xmobar/App/Main.hs | 25 |
1 files changed, 22 insertions, 3 deletions
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 |