diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index c60fb6d7..d4de3680 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -25,6 +25,7 @@ import XMonad.Util.SpawnOnce import XMonad.Layout.Magnifier import Data.Map.Strict qualified as M +import Data.Monoid import System.Posix import Graphics.X11.ExtraTypes.XF86 @@ -64,7 +65,6 @@ main = , "Signal" , "steam" , "discord" - , "vlc" ] -?> opaque @@ -101,27 +101,42 @@ main = mag tallr ||| Full , manageHook = - composeAll - [ className ~? "NautilusPreviewer" --> customFloating centeredFloat - , className =? "feh" --> customFloating buttomRightFloat - , className =? "Minder" - <&&> not <$> title ~? "Pick a Color" -- ignore the color picker - --> customFloating centeredFloat - , isFirefoxPIP --> doFloat + let + hasEvenWindows :: X Bool + hasEvenWindows = g <$> get + where g = even . length . W.integrate' + . W.stack . W.workspace . W.current . windowset - , namedScratchpadManageHook myScratchpads - ] + -- 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 + , className =? "feh" --> customFloating buttomRightFloat + , className =? "Minder" + <&&> not <$> title ~? "Pick a Color" -- ignore the color picker + --> customFloating centeredFloat + , isFirefoxPIP --> doFloat - <> - composeOne - [ className =? "firefox" -?> insertPosition Master Newer - , className =? "kitty" -?> insertPosition Below Newer - , className `isOneOf` - [ "sioyek" - , "Nautilus" - ] - -?> insertPosition End Older - ] + , namedScratchpadManageHook myScratchpads + ] + + <> + composeOne + [ className =? "firefox" -?> insertPosition Master Newer + , className =? "kitty" -?> insertPosition Below Newer + , className `isOneOf` + [ "sioyek" + , "Nautilus" + ] + -?> insertPosition End Older + , Just <$> insertInMiddle + ] } -- Only remove mappings that needs pass through (it's a map).