haskell 将XMobar迁移到新的0.17标准

xeufq47z  于 2022-11-14  发布在  其他
关注(0)|答案(1)|浏览(137)

为了清楚起见,我的XMobar现在使用UnsafeStdinReader和SpawnPipe来发送有关工作区的信息。

main = do
    xmprocleft <- spawnPipe "xmobar -x 0 $HOME/.config/xmobar/xmobarrc0.hs"
    xmonad $ docks $ ewmhFullscreen $ ewmh $ def
        { manageHook         = myManageHook <+> manageDocks
        , modMask            = myModMask
        , terminal           = myTerminal
        , startupHook        = myStartupHook
        , layoutHook         = showWName' myShowWNameTheme $ myLayoutHook
        , workspaces         = myWorkspaces
        , borderWidth        = myBorderWidth
        , normalBorderColor  = myNormColor
        , focusedBorderColor = myFocusColor
        , logHook = dynamicLogWithPP $ xmobarPP
              { ppOutput = \x -> hPutStrLn xmprocleft x                          
              , ppCurrent = xmobarColor "#f8f16a" "" . wrap "<fn=1>" "</fn>"         -- Workspace that I am viewing now
              , ppVisible = xmobarColor "#98be65" "" . wrap "<fn=1>" "</fn>" . clickable              -- Workspace that is open on any monitor other than this one
              , ppHidden = xmobarColor "#2ac3de" "" . wrap "<fn=1>" "</fn>" . clickable -- Hidden workspaces that have any open software in it but not open on any monitors
              , ppHiddenNoWindows = xmobarColor "#c0caf5" "" . wrap "<fn=1>" "</fn>" . clickable     -- Workspaces with no open softwares and not open on any monitors
              , ppTitle = xmobarColor "#c0caf5" "" . shorten 60               -- Title of active window
              , ppSep =  "<fc=#444b6a> | </fc>"                    -- Separator character
              , ppUrgent = xmobarColor "#EBCB8B" "" . wrap "!<fn=1>" "</fn>!"            -- Urgent workspace
              , ppExtras  = [windowCount]                                     -- # of windows current workspace
                 -- name of workspaces, current layout, current title of open software, number of open windows in current workspace
              , ppOrder  = \(ws:_:_:_) -> [ws]                               -- stopped showing the current layout, number of open programs in current workspace
              }
        } `additionalKeysP` myKeys

"我想达到的目标"
根据XMonad Wiki,SpawnPipe在XMonadLog的新用途中被弃用,以将数据发送到XMobar。我正在尝试根据XMonad.Hooks.StatusBar.PPXMonad.Hooks.StatusBar使用dynamicEasySBs的动态状态栏。
我也对XMobar配置做了必要的修改。但是,配置对我来说有点混乱。有人用这种新格式做了一个工作配置吗?

n53p2ov0

n53p2ov01#

在阅读新的Tutorial时,我设法更新了我的设置。
这就是您要编写xmobarrc的方式

-- appearance
   font =         "xft:Fira Code:size=11:bold:antialias=true"
   , bgColor =      "#272727"
   , fgColor =      "#073642"
   , position =     Top
   , border =       BottomB
   , borderColor =  "#646464"
   , textOffset = 11

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

   -- general behavior
   , lowerOnStart =     True    -- 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
   --   Numbers can be automatically colored according to their value. xmobar
   --   decides color based on a three-tier/two-cutoff system, controlled by
   --   command options:
   --     --Low sets the low cutoff
   --     --High sets the high cutoff
   --
   --     --low sets the color below --Low cutoff
   --     --normal sets the color between --Low and --High cutoffs
   --     --High sets the color above --High cutoff
   --
   --   The --template option controls how the plugin is displayed. Text
   --   color can be set by enclosing in <fc></fc> tags. For more details
   --   see http://projects.haskell.org/xmobar/#system-monitor-plugins.

   , commands =

        -- weather monitor
        [ Run Weather "RJTT" [ "--template", "<skyCondition> | <fc=#4682B4><tempC></fc>°C | <fc=#4682B4><rh></fc>% | <fc=#4682B4><pressure></fc>hPa"
                             ] 36000

        -- network activity monitor (dynamic interface resolution)
        , Run DynNetwork     [ "--template" , "<dev>: <tx>kB/s|<rx>kB/s"
                             , "--Low"      , "1000"       -- units: kB/s
                             , "--High"     , "5000"       -- units: kB/s
                             , "-m"         , "4"
                             , "--low"      , "darkgreen"
                             , "--normal"   , "darkorange"
                             , "--high"     , "darkred"
                             ] 10

        -- cpu activity monitor
        , Run MultiCpu       [ "--template" , "Cpu: <total0> <total1> <total2> <total3> <total4> <total5> <total6> <total7>%"
                             , "--Low"      , "50"         -- units: %
                             , "--High"     , "85"         -- units: %
                             , "-p"         , "3"
                             , "--low"      , "darkgreen"
                             , "--normal"   , "darkorange"
                             , "--high"     , "darkred"
                             ] 10

        -- cpu core temperature monitor
        , Run CoreTemp       [ "--template" , "Temp: <core0> <core1> <core2> <core3>°C"
                             , "--Low"      , "70"        -- units: °C
                             , "--High"     , "80"        -- units: °C
                             , "--low"      , "darkgreen"
                             , "--normal"   , "darkorange"
                             , "--high"     , "darkred"
                             ] 50

        -- memory usage monitor
        , Run Memory         [ "--template" ,"Mem: <usedratio>%"
                             , "--Low"      , "20"        -- units: %
                             , "--High"     , "90"        -- units: %
                             , "--low"      , "darkgreen"
                             , "--normal"   , "darkorange"
                             , "--high"     , "darkred"
                             ] 10

        -- battery monitor
        , Run Battery        [ "--template" , "Batt: <left>% - <timeleft>"
                             , "--Low"      , "10"        -- units: %
                             , "--High"     , "80"        -- units: %
                             , "--low"      , "darkred"
                             , "--normal"   , "darkorange"
                             , "--high"     , "darkgreen"

                             , "--" -- battery specific options
                                       -- discharging status
                                       , "-o"   , "<left>% (<timeleft>)"
                                       -- AC "on" status
                                       , "-O"   , "<fc=#dAA520>Charging</fc>"
                                       -- charged status
                                       , "-i"   , "<fc=#006000>Charged</fc>"
                             ] 50

        -- time and date indicator
        --   (%F = y-m-d date, %a = day of week, %T = h:m:s time)
        , Run Date           "<fc=#ABABAB>%F (%a) %T</fc>" "date" 10

        -- Xmonad Xmobar Constructor
        ,  Run XMonadLog

        ]

这应该是你的xmonad.hs

main :: IO ()
main = xmonad
     . ewmhFullscreen
     . ewmh
     . withEasySB (statusBarProp "xmobar" (pure def)) defToggleStrutsKey
     $ myConfig

符合有关dinamicLog的文档
DynamicLog API被冻结,鼓励用户迁移到这些现代的替代品。
然后是XMonad.挂钩.状态栏
这个模块提供了一个可组合的接口,可以使用管道或X属性来启动或重新启动这些状态栏并记录到它们。还有XMonad.Hooks.StatusBar.PP,它提供了一个抽象和一些实用程序来定制记录到状态栏的内容。总之,这些是XMonad.Hooks.DynamicLog的现代替代品,它现在只是一个兼容性 Package 器。

相关问题