xmonad启动时,xmobar不会出现在窗口堆栈的顶部


16

xmobar进入后马上就遇到一种奇怪的行为xmonad。当我xmonad(来自.xinitrc,我使用XDM)xmobar出现时,但它不在窗口堆栈的顶部或底部。一旦我启动了一个应用程序(例如,通过按Mod + Shift + Return进入终端仿真器),该应用程序便会使用整个屏幕,就像xmobar在底部一样。然后我按一下Mod + B,什么也没有发生,一旦我Mod + B第二次按下,xmobar就抬到顶部,减小了应用程序窗口的大小。

之后,Mod + B在剩余的xmonad会话中可以正常使用,即降低/提高(隐藏/显示)会话xmobar

我相信我配置错误。我的xmonad.hs样子:

import XMonad
import XMonad.Hooks.SetWMName
import XMonad.Hooks.DynamicLog

main = do
  xmonad =<< statusBar "xmobar" myPP toggleStrutsKey defaultConfig
    { terminal           = "urxvt"
    , focusFollowsMouse  = True
    , clickJustFocuses   = False
    , borderWidth        = 1
    , modMask            = mod4Mask
    , workspaces         = myworkspaces
    , normalBorderColor  = "#dddddd"
    , focusedBorderColor = "#00dd00"
    , manageHook         = mymanager
    , startupHook        = setWMName "LG3D"
    }

myPP = xmobarPP { ppOutput          = putStrLn
                , ppCurrent         = xmobarColor "#336433" "" . wrap "[" "]"
                --, ppHiddenNoWindows = xmobarColor "grey" ""
                , ppTitle           = xmobarColor "darkgreen"  "" . shorten 20
                , ppLayout          = shorten 6
                --, ppVisible         = wrap "(" ")"
                , ppUrgent          = xmobarColor "red" "yellow"
                }

toggleStrutsKey XConfig { XMonad.modMask = modMask } = (modMask, xK_b)

myworkspaces = [ "code"
               , "web"
               , "media"
               , "irc"
               , "random"
               , "mail"
               , "docs"
               , "music"
               , "root"
               ]

mymanager = composeAll
  [ className =? "gimp" --> doFloat
  , className =? "vlc"  --> doFloat
  ]

虽然我的.xmobarrc样子开始如下:

Config {
  -- appearance
    font =         "xft:Bitstream Vera Sans Mono:size=9:bold:antialias=true"
  , bgColor =      "black"
  , fgColor =      "#646464"
  , position =     Top
  , border =       BottomB
  , borderColor =  "#646464"

  -- layout
  , sepChar =  "%"   -- delineator between plugin names and straight text
  , alignSep = "}{"  -- separator between left-right alignment
  , template = "%battery% | %multicpu% | %coretemp% | %memory% | %dynnetwork% | %StdinReader% }{ %date% || %kbd% "

  -- general behavior
  , lowerOnStart =     False   -- send to bottom of window stack on start
  , hideOnStart =      False   -- start with window unmapped (hidden)
  , allDesktops =      True    -- show on all desktops
  , overrideRedirect = True    -- set the Override Redirect flag (Xlib)
  , pickBroadest =     False   -- choose widest display (multi-monitor)
  , persistent =       True    -- enable/disable hiding (True = disabled)

  -- plugins (i do not use any)

  , commands = [  -- actually several commands are in here
  ]
}

我尝试了以下几种组合:

, lowerOnStart =
, hideOnStart =

(正确/正确,正确/错误,错误/正确和错误/错误,如现在所示)。但是,我按Mod + B两次之前的行为不会改变。我相信我没有xmonad以某种方式配置错误,xmobar但这只是一个猜测。

.xinitrc可能会有所帮助:

#!/bin/sh

if test -d /etc/X11/xinit/xinitrc.d
then
    # /etc/X11/xinit/xinitrc.d is actually empty
    for f in /etc/X11/xinit/xinitrc.d/*
    do
        [ -x "$f" ] && source "$f"
    done
    unset f
fi

# uk keyboard
setxkbmap gb

xrdb .Xresources
xscreensaver -no-splash &

# java behaves badly in non-reparenting window managers (e.g. xmonad)
export _JAVA_AWT_WM_NONREPARENTING=1

# set the background (again, because qiv uses a different buffer)
/usr/bin/feh --bg-scale --no-fehbg -z /usr/share/archlinux/wallpaper/a*.jpg

# pulse audio for alsa
then
    /usr/bin/start-pulseaudio-x11
fi

exec xmonad

Answers:


24

两个月后,我想通了。问题是statusBar没有Hooks.manageDocks正确注册事件。一旦xmonad运行,一切都会很好,因为manageDocks能够更新Struts每个窗口事件。但是在开始的瞬间,xmonad使第一个窗口变为全屏的事件发生在事件来自之前manageDocks。这使首先打开的窗口忽略了的存在xmobar

manageDocks具有其事件处理程序,必须将其设置为最后一个事件处理程序,因此statusBar无法使用。相反,它必须使xmonad呼叫和配置xmobar手动通过dynamicLogmanageHooklayoutHookhandleEventHook。一个简单的配置是:

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) ]

这样就可以处理所有事件,docsEventHook并确保对布局所做的更改docsEventHook是最后一次应用。现在

lowerOnStart = False

(或True)按预期在所有情况xmobarrc


1
您也可以使用statusBar并覆盖,handleEventHook = handleEventHook defaultConfig <+> docksEventHook直到修复DynamicLog软件包为止。
timakro

2

将您的配置与我的较简单配置(在这方面可以正常工作)进行比较,我看到一个可能有所不同的区别:

general behaviour我只有的所有选择

lowerOnStart = True

而不是一个hideOnStartoverrideRedirect等等。

据我所知,在其中添加xmobar的方式xmonad.hs与我的相同。

在这种情况下,我将尝试使用尽可能多的默认设置,例如,重命名.xmobarrc以免被选中,然后更改xmonad.hs

main = xmonad =<< statusBar "xmobar" xmobarPP toggleStrutsKey defaultConfig
toggleStrutsKey XConfig { XMonad.modMask = modMask } = (modMask, xK_b)

看看是否可行。稍后一点一点地添加,看看它何时中断。


谢谢,您的回答提醒我,我应该从empty调试它xmonad.hs。那让我发现了实际的问题:)
令人讨厌的
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.