Cleanly respawning xmobar when reload xmonad
Solution 1:
Not xmonad specific, but you could launch xmobar through a shell script that checks for an existing xmobar process. See, e.g., http://bash.cyberciti.biz/web-server/restart-apache2-httpd-shell-script/
Solution 2:
If you have a shell script to start XMobar then you are 'doing it wrong'. You should be starting xmobar using the correct Haskell functions in the xmonad.hs config source file. Take a look at my configs main function:
-- put it all together
main = do
nScreens <- countScreens -- just in case you are on a laptop like me count the screens so that you can go
xmonad =<< xmobar myBaseConfig
{ modMask = myModMask
, workspaces = withScreens nScreens myWorkspaces
, layoutHook = myLayoutHook nScreens
, manageHook = myManageHook
, borderWidth = myBorderWidth
, normalBorderColor = myNormalBorderColor
, focusedBorderColor = myFocusedBorderColor
, keys = myKeys
, mouseBindings = myMouseBindings
, logHook = myLogHook
}
where
myLogHook = dynamicLogXinerama
myBaseConfig = gnomeConfig
The salient line is this one:
xmonad =<< xmobar myBaseConfig
That runs xmobar as it should be run, even when you reload xmonad. You get the 'xmobar' function from the statement:
import XMonad.Hooks.DynamicLog (xmobar)
Which in turn comes from the xmonad-contrib package.
So you see, most things that you want to do with XMonad are already a solved problem, you just have to know where to look. Basically, just ditch your script and use that instead. I hope this helps.