重新加载 xmobar 的配置

重新加载 xmobar 的配置

我很高兴使用莫巴西莫纳德作为我的窗口管理器。

当改变xmonad的配置时,我使用mod+q来使新的配置生效。

这对于 xmonad 来说很好,但我注意到 xmobar 不会重新加载其配置。

我如何重新加载 xmobar 的配置?


我当前的配置xmonad.hs

import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

main = do

  xmproc <- spawnPipe "xmobar"

  xmonad $ defaultConfig {
          manageHook = manageDocks <+> manageHook defaultConfig
        , layoutHook = avoidStruts  $
                      layoutHook defaultConfig
        -- Without this, the xmonad pane would hide xmobar
        -- From https://unix.stackexchange.com/questions/288037/xmobar-does-not-appear-on-top-of-window-stack-when-xmonad-starts/303242
        , handleEventHook = handleEventHook defaultConfig <+> docksEventHook
        , logHook = dynamicLogWithPP xmobarPP
                        { ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "green" "" . shorten 50
                        }
        , modMask = mod4Mask     -- Rebind Mod to the Windows key
        , terminal = "urxvt"
        , borderWidth = 1
        , normalBorderColor = "#edf9ee"
        , focusedBorderColor = "dark green"
        , focusFollowsMouse = False
        } `additionalKeys`
        [
          -- Toggle xmobar using mod + b
          ((mod4Mask, xK_b), sendMessage ToggleStruts)
          -- Make a screenshot of the whole screen with the print key
        , ((0, xK_Print), spawn "import -window root screenshot_$(date +%F_%H-%M-%S).png")
        ]

这是来自的配置.xmobarrc

-- Configure the status bar for xmonad: https://wiki.archlinux.org/index.php/Xmobar
Config { font = "-*-Fixed-Bold-R-Normal-*-15-*-*-*-*-*-*-*"
        , borderColor = "black"
        , border = TopB
        , bgColor = "blue"
        , fgColor = "grey"
        , position = TopW L 100
        , commands = [ Run MultiCpu ["-t","Cpu: <total0> <total1> <total2> <total3>","-L","30","-H","60","-h","#FFB6B0","-l","#CEFFAC","-n","#FFFFCC","-w","3"] 10
                     , Run Memory ["-t","Mem: <usedratio>%"] 10
                     , Run Battery ["-t","Bat: <left>% / <timeleft>","-L","30","-H","60","-h","green","-n","yellow","-l","red"] 10
                     , Run Com "uname" ["-s","-r"] "" 36000
                     , Run Date "%a %F %H:%M" "date" 10
                     ]
        , sepChar = "%"
        , alignSep = "}{"
        , template = "%multicpu% | %memory% | %battery%}{<fc=#ee9a00>%date%</fc> | %uname% "
        , hideOnStart = False
        , persistent = True
        }

答案1

如果您已设置 xmonad 来启动 xmobar,如下所示:

main = xmonad <=< xmobar $ defaultConfig
        { terminal = "xterm"
        -- , modMask = mod4Mask
        , borderWidth = 3
        } `additionalKeys`
        [ ((mod1Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -l")
        ]

然后您只需重新加载 xmonad 即可使用mod-q重新加载 xmonad 和 xmobar。

答案2

由于 xmonad 可以正常显示重新启动的 xmobar,我使用

killall xmobar; xmobar &

在我的终端上使更改.xmobarrc生效。

答案3

我是 xmonad 的新手,我将我的 Mod+q(刷新 xmonad)从

xmonad --recompile; xmonad --restart

xmonad --recompile; killall xmobar; xmonad --restart

当尝试改变条形大小和 Mod+q 时,它工作正常。

相关内容