mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-26 09:41:52 -07:00
X.U.Loggers: Add logTitlesOnScreen
This works like logTitles, but gets an explicit screen to log the window titles on. This may be useful when having status bars for each screen that show all windows on their respective visible workspaces.
This commit is contained in:
@@ -36,7 +36,7 @@ module XMonad.Util.Loggers (
|
||||
-- * XMonad: Screen-specific Loggers
|
||||
-- $xmonad-screen
|
||||
, logCurrentOnScreen, logLayoutOnScreen
|
||||
, logTitleOnScreen, logWhenActive
|
||||
, logTitleOnScreen, logWhenActive, logTitlesOnScreen
|
||||
-- * Formatting Utilities
|
||||
-- $format
|
||||
, onLogger
|
||||
@@ -174,8 +174,8 @@ maildirNew mdir = logFileCount (mdir ++ "/new/") (not . isPrefixOf ".")
|
||||
logTitle :: Logger
|
||||
logTitle = withWindowSet $ traverse (fmap show . getName) . W.peek
|
||||
|
||||
-- | Get the titles of all windows on the current workspace and format
|
||||
-- them according to the given functions.
|
||||
-- | Get the titles of all windows on the visible workspace of the given
|
||||
-- screen and format them according to the given functions.
|
||||
--
|
||||
-- ==== __Example__
|
||||
--
|
||||
@@ -188,14 +188,14 @@ logTitle = withWindowSet $ traverse (fmap show . getName) . W.peek
|
||||
-- > formatFocused = wrap "[" "]" . xmobarColor "#ff79c6" "" . shorten 50 . xmobarStrip
|
||||
-- > formatUnfocused = wrap "(" ")" . xmobarColor "#bd93f9" "" . shorten 30 . xmobarStrip
|
||||
--
|
||||
logTitles
|
||||
:: (String -> String) -- ^ Formatting for the focused window
|
||||
logTitlesOnScreen
|
||||
:: ScreenId -- ^ Screen to log the titles on
|
||||
-> (String -> String) -- ^ Formatting for the focused window
|
||||
-> (String -> String) -- ^ Formatting for the unfocused window
|
||||
-> Logger
|
||||
logTitles formatFoc formatUnfoc = do
|
||||
winset <- gets windowset
|
||||
let focWin = W.peek winset
|
||||
wins = W.index winset
|
||||
logTitlesOnScreen sid formatFoc formatUnfoc = (`withScreen` sid) $ \screen -> do
|
||||
let focWin = fmap W.focus . W.stack . W.workspace $ screen
|
||||
wins = maybe [] W.integrate . W.stack . W.workspace $ screen
|
||||
winNames <- traverse (fmap show . getName) wins
|
||||
pure . Just
|
||||
. unwords
|
||||
@@ -203,6 +203,13 @@ logTitles formatFoc formatUnfoc = do
|
||||
wins
|
||||
winNames
|
||||
|
||||
-- | Like 'logTitlesOnScreen', but directly use the "focused" screen
|
||||
-- (the one with the currently focused workspace).
|
||||
logTitles :: (String -> String) -> (String -> String) -> Logger
|
||||
logTitles formatFoc formatUnfoc = do
|
||||
sid <- gets $ W.screen . W.current . windowset
|
||||
logTitlesOnScreen sid formatFoc formatUnfoc
|
||||
|
||||
-- | Get the name of the current layout.
|
||||
logLayout :: Logger
|
||||
logLayout = withWindowSet $ return . Just . ld
|
||||
|
Reference in New Issue
Block a user