首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将XMobar迁移到新的0.17标准

将XMobar迁移到新的0.17标准
EN

Stack Overflow用户
提问于 2022-07-30 02:13:41
回答 1查看 183关注 0票数 1

为了说明这一点,我的XMobar现在使用UnsafeStdinReader和SpawnPipe发送有关工作区的信息。以下是配置的相关部分:

代码语言:javascript
复制
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维基的说法,SpawnPipe不再推荐使用XMonadLog来向XMobar发送数据。我试图使用动态状态栏使用dynamicEasySBs,根据XMonad.Hooks.StatusBar.PPXMonad.Hooks.StatusBar

我也对XMobar配置做了必要的更改。但是,这个配置对我来说有点混乱。是否有人使用这种新格式进行了工作配置?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-09-23 10:16:07

在阅读新的教程时,我设法以这种方式更新我的设置。

这就是您想要编写xmobarrc的方式。

代码语言:javascript
复制
 -- 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

代码语言:javascript
复制
main :: IO ()
main = xmonad
     . ewmhFullscreen
     . ewmh
     . withEasySB (statusBarProp "xmobar" (pure def)) defToggleStrutsKey
     $ myConfig

根据这个关于dinamicLog的文档

DynamicLog API被冻结,并鼓励用户迁移到这些现代替代品。

那就是XMonad.Hooks.StatusBar

该模块提供了一个可组合的接口,用于启动这些状态栏并使用管道或X属性对它们进行日志记录。还有XMonad.Hooks.StatusBar.PP,它为定制记录到状态栏的内容提供了一个抽象和一些实用程序。总之,这些都是XMonad.Hooks.DynamicLog的现代替代品,现在它只是一个兼容性包装器。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73172417

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档