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
答案1
两个月后我想通了。问题是statusBar
没有正确注册事件Hooks.manageDocks
。一旦xmonad
运行一切正常,因为manageDocks
能够更新Struts
每个窗口事件。但在开始时,xmonad
使第一个窗口全屏的事件发生在来自 的事件之前manageDocks
。这使得第一次打开的窗口忽略了 的存在xmobar
。
manageDocks
有它的事件处理程序必须被设置为最后一个事件处理程序,因此statusBar
无法使用。而是需要通过、、 、手动xmonad
调用和配置。一个简约的配置是:xmobar
dynamicLog
manageHook
layoutHook
handleEventHook
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
。
答案2
将您的配置与我的更简单的配置进行比较(在这方面确实可以正常工作),我发现一个可能会有所作为的差异:
在general behaviour
你所有的选择中我只有
lowerOnStart = True
并且没有一个hideOnStart
,overrideRedirect
等等。
xmonad.hs
据我所知,添加 xmobar 的方式与我的相同。
在这种情况下,我会尝试使用尽可能多的默认设置,例如重命名,.xmobarrc
这样它就不会被拾取,然后更改xmonad.hs
为例如
main = xmonad =<< statusBar "xmobar" xmobarPP toggleStrutsKey defaultConfig
toggleStrutsKey XConfig { XMonad.modMask = modMask } = (modMask, xK_b)
看看它是否有效。后来一点一点地添加,看看什么时候会破裂。