xmobar does not appear on top of window stack when xmonad starts
Two months later I figured it out. The problem is that statusBar
does not register the events of Hooks.manageDocks
properly. Once xmonad
is running all works well because manageDocks
is able to update the Struts
on every window event. But in the moment that xmonad
is starting the event of making the first windows fullscreen happens before the events from manageDocks
. This mages that first open window to ignore the existence of xmobar
.
manageDocks
has its event handler that must be set as the last event handler, therefore statusBar
cannot be used. Instead, it is necessary to make xmonad
call and configure xmobar
manually through dynamicLog
, manageHook
, layoutHook
and handleEventHook
. A minimalistic configuration for this would be:
main = do
xmproc <- spawnPipe "xmobar"
xmonad $ defaultConfig
{ modMask = mod4Mask
, manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
-- this must be in this order, docksEventHook must be last
, handleEventHook = handleEventHook defaultConfig <+> docksEventHook
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "darkgreen" "" . shorten 20
, ppHiddenNoWindows = xmobarColor "grey" ""
}
, startupHook = setWMName "LG3D"
} `additionalKeys`
[ ((mod4Mask, xK_b), sendMessage ToggleStruts) ]
This makes all events to be processed by docsEventHook
and ensures that layout changes made by docsEventHook
are the last ones applied. Now
lowerOnStart = False
(or True
) works as expected in all cases within xmobarrc
.
Comparing your config, to my simpler one, which does work correctly in this regard, I see one difference that might do something:
from all the general behaviour
options you have I only have
lowerOnStart = True
and not a single of hideOnStart
, overrideRedirect
etc.
The way you add xmobar in xmonad.hs
is, as far as I can read, the same as mine.
In this case I'd try with as much default settings as possible, e.g. rename .xmobarrc
so it's not picked up, and change xmonad.hs
to e.g.
main = xmonad =<< statusBar "xmobar" xmobarPP toggleStrutsKey defaultConfig
toggleStrutsKey XConfig { XMonad.modMask = modMask } = (modMask, xK_b)
and see if it works. Later add bit by bit, and see when it breaks.