xmonad / xmonad

The core of xmonad, a small but functional ICCCM-compliant tiling window manager
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
3.34k stars 290 forks source link

dzen2 bar dissappears a second after issuing startx command #141

Closed sct0 closed 3 years ago

sct0 commented 6 years ago

Problem Description

When I issue the startx command in my startup terminal, xmonad starts up as expected but my dzen2 bar only shows up for a second and then dissappears. I first thought it had to do with issue https://github.com/xmonad/xmonad/issues/21 , until I realised that the bar disappears even when don't open a window.

I am running Gentoo 4.4.12 with xmonad 0.13.

Configuration File

import XMonad 
import qualified XMonad.StackSet as W
import qualified XMonad.Util.CustomKeys as C
import qualified Data.Map as M
import XMonad.Prompt
import XMonad.Prompt.RunOrRaise
import XMonad.Config.Desktop
import XMonad.Util.Run(spawnPipe)

myXmonadBar = "dzen2 -x 0 -y 0 -h '24' -w '640' -ta 'l' -fg '#ffff00' -bg '#33cc33'"
main :: IO ()
main = do
dzenLeftBar <- spawnPipe myXmonadBar
xmonad $ desktopConfig
       { borderWidth        = 0
       , terminal           = "urxvt -bg black -fg white -vb +sb"
       , workspaces         = ["shell", "web"] ++ map show [3..9]
       , normalBorderColor  = "#000000"
       , focusedBorderColor = "#000000"
       , keys = C.customKeys delkeys inskeys
       , manageHook         = manageHook defaultConfig <+> myManageHook
       }
    where
      delkeys :: XConfig l -> [(KeyMask, KeySym)]
      delkeys XConfig {modMask = modm} =
          [ (modm, xK_b) ]

      inskeys :: XConfig l -> [((KeyMask, KeySym), X ())]
      inskeys conf@(XConfig {modMask = modm}) =
          let font = "Monospace"
              color = "-fg white -bg black"
              urxvt = "urxvt -vb +sb" in 
          [ 
           ((modm .|. shiftMask, xK_w), spawn "firefox"),
           ((modm .|. shiftMask, xK_e), spawn 
            ("emacs --font \"" ++ font ++ "-14\" " ++ color)),
           ((modm .|. shiftMask, xK_u), spawn 
            (urxvt ++ " " ++ color ++ " -fn \"xft:" ++ font ++ 
             ":pixelsize=20\"")),
           ((modm .|. shiftMask, xK_l), spawn "xlock -mode blank")
          ]
      myManageHook :: ManageHook
      myManageHook = composeAll [
                      className   =? "Firefox-bin" --> doF(W.shift "web")
                     ]

I used the issue above and the following two links to build my config.

https://wiki.haskell.org/Xmonad/Config_archive/brad%27s_xmonad.hs http://thinkingeek.com/2011/11/21/simple-guide-configure-xmonad-dzen2-conky/

sct0 commented 6 years ago

Okey, so, I went through the command line option and found the -p option which solved the issue, though I am not entirely sure what it does and why it wasn't mentioned in the guide.

su8 commented 6 years ago

My dzen status bar dissapears too from time to time, roughly once in every 4-6 months. And only a system reboot fixes it.

QiBaobin commented 6 years ago

xmobar process died from time to time here, restart xmonad fixes, not sure if it's related.

liskin commented 3 years ago

@sct-0 dzen2 disappears because you're not using the dzenLeftBar pipe anywhere at all, so the garbage collector closes it, dzen2 gets an end-of-file and exits. Why do you want a dzen2 with no input anyway?

Here's some docs about it: https://github.com/xmonad/xmonad-contrib/blob/97289ff6ca1f0edd0447870b9dcbe9a4b6858d9b/XMonad/Hooks/DynamicLog.hs#L128

Also, these days you might want to use https://xmonad.github.io/xmonad-docs/xmonad-contrib-0.16.999/XMonad-Hooks-StatusBar.html which makes it much harder to make this kind of mistake.