Skip to content

X.H.SB.PP: Added ppCurrentNoWindows#962

Open
fpeterek wants to merge 2 commits intoxmonad:masterfrom
fpeterek:pp-current-no-windows
Open

X.H.SB.PP: Added ppCurrentNoWindows#962
fpeterek wants to merge 2 commits intoxmonad:masterfrom
fpeterek:pp-current-no-windows

Conversation

@fpeterek
Copy link

@fpeterek fpeterek commented Dec 15, 2025

Description

We already have ppVisibleNoWindows and ppHiddenNoWindows, this change adds the missing ppCurrentNoWindows printer, as well as matching predicates (isCurrentNoWindows, isCurrentHasWindows, hasWindows). isCurrent remains as was and doesn't care about windows. However, the new predicates allow you to check whether a layout is the current one but also contains/doesn't contain windows. ppCurrentNoWindows falls back to ppCurrent if set to Nothing (also the default value), so existing configurations should not break in any way, but can be extended easily.

This PR shouldn't break anything as the existing public API remains unchanged, with only slight internal implementation changes and new additions to the API.

It's also not strictly necessary, you could achieve similar results by using ppPrinters and creating a custom predicate, but that just seems like an inconsistent and complicated way to do it, when we already have the other two printers. The change in code is rather small and could simplify configuration for some users.

In the first picture, the workspace has at least one window open.

current

And here's an example of the current workspace not having any windows open.

current-no-windows

Sample configuration, which should allow you to reproduce the example with Xmobar.

xmobarPP' :: PP
xmobarPP' = def
    { ppCurrent          = pad . xmobarBorder "Bottom" "#6dcbfa" 3 . white
    , ppCurrentNoWindows = Just $ pad . xmobarBorder "Bottom" "#6dcbfa" 3 . gray
    , ppVisible          = pad . xmobarBorder "Bottom" "#215975" 3 . white
    , ppVisibleNoWindows = Just $ pad . xmobarBorder "Bottom" "#215975" 3 . gray
    , ppHidden           = white . pad
    , ppHiddenNoWindows  = gray . pad
    }
  where
      white        = xmobarColor "#e0e0e0" ""
      gray         = xmobarColor "#89878e" ""

Checklist

  • [*] I've read CONTRIBUTING.md

  • [*] I've considered how to best test these changes (property, unit,
    manually, ...) and concluded: Test manually, swap to a workspace with no windows

  • [*] I updated the CHANGES.md file

We already have `ppVisibleNoWindows` and `ppHiddenNoWindows`,
this change adds the missing `ppCurrentNoWindows` printer,
as well as matching predicates (`isCurrentNoWindows`, `hasWindows`).
@geekosaur
Copy link
Contributor

I will wait to see what Solid has to say, but my initial reaction is that breaking an API going back to 2007 is probably not the greatest of ideas, especially when it'd be silent breakage.

@fpeterek
Copy link
Author

Fair point, we can also change the predicates to make the change non-breaking, at the cost of inconsistency (probably worth it). Adding just the printer should not break anything.

If you want to merge it in some form or another, lmk, I can change the PR. Or you can just close it, I don't care either way, I'm just recently switching to XMonad and found this surprisingly difficult to configure for what it is, but I'm fine just changing my own config.

@slotThe
Copy link
Member

slotThe commented Dec 15, 2025

I will wait to see what Solid has to say, but my initial reaction is that breaking an API going back to 2007 is probably not the greatest of ideas, especially when it'd be silent breakage.

Yeah, I think I would agree. Perhaps a separate printer would be better

@TheMC47
Copy link
Member

TheMC47 commented Dec 15, 2025

I will wait to see what Solid has to say, but my initial reaction is that breaking an API going back to 2007 is probably not the greatest of ideas, especially when it'd be silent breakage.

Yeah, I think I would agree. Perhaps a separate printer would be better

or just a logger?

@slotThe
Copy link
Member

slotThe commented Dec 15, 2025 via email

@fpeterek fpeterek force-pushed the pp-current-no-windows branch from 42d126c to f831d7e Compare December 17, 2025 22:30
@fpeterek
Copy link
Author

Thanks for the input (and the approval that came before I could even write a comment).

Here's a better proposal, one that doesn't break the API, only adds new functionality. There's a fallback which should ensure existing configurations still work, but hopefully this will make XMobar a bit easier to configure.

If you have any further comments/remarks, let me know, I'm happy to incorporate them.

Copy link
Member

@TheMC47 TheMC47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was checking the code again, and I'm not sure of extending the PP type for every predicate (and I'm not sure where we should draw the line).

Did you check the ppPrinters API?You could add your own predicate with your own format, and it will take precedence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants