From a1636c65e05d02f7d4fc408137e1d37b412ce890 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Sun, 20 Nov 2022 18:31:39 -0700 Subject: Add better theater reporting to xmobar --- src/Rahm/Desktop/XMobarLog.hs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/Rahm/Desktop/XMobarLog.hs') diff --git a/src/Rahm/Desktop/XMobarLog.hs b/src/Rahm/Desktop/XMobarLog.hs index 9ea8bad..e419739 100644 --- a/src/Rahm/Desktop/XMobarLog.hs +++ b/src/Rahm/Desktop/XMobarLog.hs @@ -4,7 +4,7 @@ import Control.Arrow (second) import Control.Monad (forM_) import Control.Monad.Writer (tell, execWriter) import Data.List (sortBy) -import Data.Maybe (mapMaybe) +import Data.Maybe (mapMaybe, isJust) import Data.Ord (comparing) import Data.Char (isAsciiLower, isAsciiUpper, isDigit) import Rahm.Desktop.Layout.Draw (drawLayout) @@ -15,7 +15,7 @@ import XMonad (X) import Rahm.Desktop.Workspaces (getPopulatedWorkspaces, WorkspaceState(..)) import Text.Printf import Rahm.Desktop.Logger -import Rahm.Desktop.Theater (getCurrentTheaterName) +import Rahm.Desktop.Theater (getTheaters) import qualified XMonad as X import qualified Rahm.Desktop.StackSet as S @@ -42,7 +42,7 @@ xMobarLogHook (XMobarLog xmproc) = do (_, _, layoutXpm) <- drawLayout loglevel <- getLogLevel - currentTheater <- getCurrentTheaterName + theaters <- filter (\(j, _, _) -> isJust j) <$> getTheaters winset <- X.gets X.windowset title <- maybe (pure "") (fmap show . getName) . S.peek $ winset @@ -54,13 +54,22 @@ xMobarLogHook (XMobarLog xmproc) = do tell " " tell $ logLevelToXMobar loglevel - case currentTheater of - Just theater -> do - tell "[" - tell theater - tell "] " + forM_ theaters $ \theater -> case theater of + (Just n, _, True) -> do + tell "" + tell n + tell " " - Nothing -> tell " " + (Just n, _, False) -> do + tell "" + tell n + tell " " + + _ -> return () + + if not (null theaters) + then tell "| " + else return () forM_ wss $ \(t, ws) -> do case t of -- cgit