How to configure StdinReader to only show workspaces?

1.3k Views Asked by At

I have a very simple xmonad/xmobar configuration, with this on the left hand side of xmobar:

[1] 2 : Tall : How to configure StdinReader to only ...

How can I remove the layout name and window title? (Tall and How to ...) ??

I can see the template in xmobarrc2 looks like this:

template = "%StdinReader%}{<fc=#FFF>%date%</fc>"

So it looks like StdinReader provides all 3 of those items, but how can I configure this? I can't seem to find anything useful about this, except maybe UnsafeStdinReader, but I really don't get how it works, or how I'm supposed to go about researching this..

Can anyone point me in the right direction?

My entire xmobarrc2:

    Config { font = "xft:Ubuntu Mono:pixelsize=16:antialias=true:hinting=true"
            , borderColor = "black"
            , border = TopB
            , bgColor = "black"
            , fgColor = "grey"
            , position = TopP 0 0
            , commands = [ 
                      Run Weather "CYVR" ["-t","<tempC>C","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000
                    , Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 10
                    , Run Network "eth1" ["-L","0","-H","32","--normal","green","--high","red"] 10
                    , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
                    , Run Memory ["-t","Mem: <usedratio>%"] 10
                    , Run Swap [] 10
                    , Run Com "uname" ["-s","-r"] "" 36000
                    , Run Date "%a %_d.%_m  %H:%M" "date" 10
                    , Run StdinReader
                            ]
            , sepChar = "%"
            , alignSep = "}{"
            , template = "%StdinReader%}{<fc=#FFF>%date%</fc>"
            }
1

There are 1 best solutions below

7
On BEST ANSWER

You have a lot of commands defined in your xmobarrc2 (Weather, Network, Cpu, Memory, Swap, Com, StdinReader and Date) but the only ones you actually use in your template are StdinReader and Date (you could delete the others if you wanted to). Now, while Date works (and is formatted) as defined above, StdinReader just reproduces the (pre-formatted) output of XMonad. Therefore, the place to change what you want to have changed is in your xmonad.hs.

XMonad uses logHooks to report on internal state updates such as window titles, focus changes etc. Such a logHook is typically used to pipe those informations into a status bar. XMonad.Hooks.StatusBarPP implements a logHook defining a pretty-printer (PP) to format the content to be output. This module also defines xmobarPP which additinally implements some specific features such as setting the colors in a way XMobar expects them (<fc=#FFF>…</fc>), etc. Thus, with XMobar, you typically install a logHook using xmobarPP.

These pretty-printers allow the user to customize the formatting using specific functions. One of them is

ppOrder :: [String] -> [String]

which by default is called with a list of strings being (in this order) the workspaces, the layout, the current window title, and anything you have defined using another function called ppExtras. To only have the workspaces, redefine it as:

ppOrder = \(ws:_) -> [ws]

Summing up, your xmonad.hs will need something along the lines of:

main = do
  -- ...
  xmproc2 <- spawnPipe "xmobar path/to/your/xmobarrc2"
  -- ...
  xmonad $ ewmh desktopConfig
    { 
      -- ...
      , logHook = dynamicLogWithPP xmobarPP
          { 
            -- ...
            , ppOutput = hPutStrLn xmproc2
            , ppExtras = []
            , ppOrder = \(ws:_) -> [ws]
            -- ...
          }
      -- ...
    }
  -- ...