0

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>"
            }
Bassie
  • 9,529
  • 8
  • 68
  • 159

1 Answers1

1

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]
            -- ...
          }
      -- ...
    }
  -- ...
pmf
  • 24,478
  • 2
  • 22
  • 31
  • Thanks pmf. Where are you getting all this information? for example, how would I find out about `[ws]` or `\(ws:_)`? My xmonad.hs looks so different to what you posted, I am going to have to play around with it and figure out how it maps to yours – Bassie Dec 28 '21 at 18:41
  • XMonad is written and configured in [Haskell](https://en.wikipedia.org/wiki/Haskell_(programming_language)). To find information on how it works, you need to look up the modules that are being used (internally or as imports in your `xmonad.hs` configuration file), just like I suggested with [XMonad.Hooks.StatusBarPP](https://hackage.haskell.org/package/xmonad-contrib-0.17.0/docs/XMonad-Hooks-StatusBar-PP.html). – pmf Dec 28 '21 at 21:23
  • The rest is just basics of the Haskell programming language - in this particular case defining a [lambda function](https://www.haskell.org/tutorial/functions.html) by [pattern matching](https://www.haskell.org/tutorial/patterns.html) and handling [lists](https://www.haskell.org/tutorial/arrays.html): `ws:_` matches the input list and grabs its first element, `[ws]` reproduces it as a one-item list, and `\x -> … x …` defines this as an "anonymous" function matching the [type signature](https://www.haskell.org/onlinereport/decls.html#type-signatures) figured out from the module's documentation. – pmf Dec 28 '21 at 21:23
  • I can't get this working at all - @pmf do you remember which version this applies to? I noticed some notes about xmobar working differently from version 0.1.7, wondering if that's it? I am getting e.g. `variable not in scope : spawnPipe` – Bassie Dec 31 '21 at 11:04
  • `spawnPipe` resides in [XMonad.Util.Run](https://hackage.haskell.org/package/xmonad-contrib-0.17.0/docs/XMonad-Util-Run.html). Did you `import` it? – pmf Dec 31 '21 at 11:08
  • Thanks pmf, I finally got it to work as per your example here. One issue I noticed is that if I replace `desktopConfig` with some `myConfig`, it seems that xmobar is covered up by my windows (can only see it on empty workspace) do you happen to know why it could be ? – Bassie Dec 31 '21 at 11:18
  • 1
    Look into `avoidStruts` in [XMonad.Hooks.ManageDocks](https://hackage.haskell.org/package/xmonad-contrib-0.17.0/docs/XMonad-Hooks-ManageDocks.html) – pmf Dec 31 '21 at 11:21