vanadium/xmonad: refactor manage gook

This commit is contained in:
Primrose 2025-09-07 17:34:50 +08:00
parent bbf6651440
commit 5539bed063
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -24,6 +24,7 @@ import XMonad.Util.NamedScratchpad
import XMonad.Util.SpawnOnce
import Data.Map.Strict qualified as M
import Data.Monoid (Endo(Endo))
import Graphics.X11.ExtraTypes.XF86
import System.Posix
@ -49,12 +50,6 @@ main =
, logHook =
let
isOneOf :: Eq a => Query a -> [a] -> Query Bool
isOneOf q = fmap or . traverse (q =?)
isFocused :: Query Bool
isFocused = fmap not isUnfocused
fadeHook =
composeOne
[ -- easier to paint over stuff
@ -107,9 +102,16 @@ main =
let
hasEvenWindows :: X Bool
hasEvenWindows = g <$> get
where g =
even . length . W.integrate'
. W.stack . W.workspace . W.current . windowset
where g = even . length . W.integrate'
. W.stack . W.workspace . W.current . windowset
-- When having a lot of windows this will converge into the middle of the stack
insertInMiddle :: Query (Endo WindowSet)
insertInMiddle =
ifM
(liftX hasEvenWindows)
(insertPosition Below Newer) -- New window is odd
(insertPosition Above Newer) -- New window is even
in
composeAll
[ className ~? "NautilusPreviewer" --> customFloating centeredFloat
@ -121,15 +123,14 @@ main =
<>
composeOne
[ className =? "firefox" -?> insertPosition Above Newer
, className =? "sioyek" -?> insertPosition Below Older
, className =? "kitty" -?> insertPosition Below Newer
, className ~? "Nautilus" -?> insertPosition Below Older -- For some reason Older doesn't work
, ifM
(liftX hasEvenWindows)
(Just <$> insertPosition Below Newer) -- New window is odd
(Just <$> insertPosition Above Newer) -- New window is even
[ className =? "firefox" -?> insertPosition Master Newer
, className =? "kitty" -?> insertPosition Below Newer
, className `isOneOf`
[ "sioyek"
, "Nautilus"
]
-?> insertPosition End Older
, Just <$> insertInMiddle
]
}
@ -270,6 +271,13 @@ xmobarConfig = statusBarProp "xmobar -x 0" (pure myPrettyPrinter)
, ppSep = " | "
}
isOneOf :: Eq a => Query a -> [a] -> Query Bool
isOneOf q = fmap or . traverse (q =?)
isFocused :: Query Bool
isFocused = fmap not isUnfocused
isFirefoxPIP :: Query Bool
isFirefoxPIP =
className =? "firefox"