Search code examples
haskellwindow-managersxmonad

xmonad: move new floating windows


As described in this and this issue, my floating windows are sometimes rendered behind other windows when using xmonad together with compton. One possible workaround I want to try is to make xmonad move new floating windows slightly, which should render them above other windows. However, being new to xmonad and Haskell, I have no idea how to achieve this.

How do I tell xmonad "When a new floating window is created, move it one pixel to the right"?

(xmonad-0.10 and xmonad-contrib-0.10)


Solution

  • For people coming here who really want to shift a window, here is how you do it:

    In your $HOME/.xmonad.xmonad.hs:

    Add some imports (you can skip existing, note the qualified import of Xmonad.StackSet and the "W.shift" below, you will have to adjust the name if you imported it under another name)

    import XMonad.Hooks.XPropManage
    import qualified XMonad.StackSet as W
    import XMonad.Actions.TagWindows
    import Data.List
    

    And add

    manageHook = xPropManageHook xPropMatches
    
    xPropMatches :: [XPropMatch]
    xPropMatches = [ ( [(wM_CLASS, any (const True))], (return (W.shift "2"))) ]
    

    that should work for all windows. If you want to control the matching,

    (const True)
    

    can be replaced with anything that has the type

    String -> Bool
    

    e.g.

    ("Vimperator" `isInfixOf`)
    

    etc

    Source: XPropManage