Xmonad

xmonad 啟動時,xmobar 不會出現在視窗堆棧的頂部

  • August 13, 2016

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

兩個月後,我想通了。問題是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

引用自:https://unix.stackexchange.com/questions/288037