Stebalien / i3bar.el

An Emacs package for displaying the output of an i3status compatible command in the mode-line or tab-bar.
https://stebalien.com/projects/i3bar-el/
GNU General Public License v3.0
15 stars 3 forks source link

feature request: support for xmobar ansi mode #3

Open jaor opened 2 years ago

jaor commented 2 years ago

xmobar can output status lines as plain text with ANSI color escapes (flag -TAnsi).

in that mode, every line of output represents the concatenation of all "blocks" (monitor outputs in xmobar's lingo): any separators between them are specified directly in xmobar's configuration, so no block consolidation would be needed for supporting this.

on just needs to detect end of line in the output, process the ansi escapes and assign that to i3bar-string. i've noticed that ansi-color-apply only translates basic color escapes, which is fine. optionally, one could use the package xterm-color, which is able to translate 256 colors, so it'd be nice if the "ansi color filter function" were customizable (no need to introduce a hard dependency on that package, unless you prefer to).

Stebalien commented 2 years ago

Ah, so, I misunderstood your original proposal. If xmobar isn't speaking the i3bar protocol at all in this mode, it probably doesn't make sense to implement support in this package (as it's almost entirely focused on parsing i3bar output).

jaor commented 2 years ago

On Mon, Aug 08 2022, Steven Allen wrote:

Ah, so, I misunderstood your original proposal. If xmobar isn't speaking the i3bar protocol at all in this mode, it probably doesn't make sense to implement support in this package (as it's almost entirely focused on parsing i3bar output).

xmobar can also output i3bar style JSON, but there it uses the "background"/"foreground" properties of the JSON for colors and pango for font families. so, after your latest addition of a catch for the end-of-file error, it works practically out of the box when no special face families are used.

it's just that simply parsing ansi colours instead would be much more efficient. if you don't think that's worth the trouble, just a note in the docs might be nice: all that is needed is

  (setq i3bar-command '("xmobar" "-TSwaybar"))

or, if one has a config file:

  (setq i3bar-command '("xmobar" "-TSwaybar" "path/to/config"))

and an xmobar confguration that doesn't use additionalFonts (xmobar users will know what that means).

but i can also add that to xmobar's docs, so please feel absolutely free to close the issue instead :)

thanks! -- How many Zen Buddhist does it take to change a light bulb? Two. One to change it and one not to change it.

jaor commented 2 years ago

@Stebalien i couldn't help it and put together a quick package that uses xmobar's ansi output, shamelessly stealing from i3bar: https://codeberg.org/jao/elibs/src/branch/main/lib/eos/xmobar.el

it's almost trivial... which i guess makes it a bit of a pity that it's essentially duplicating a subset of what you already have here. but if you prefer we keep them separate, that's also good in other ways, so up to you!

Stebalien commented 2 years ago

Yeah, the thing is that this would also apply to conky support, and more. But you're right, it's pretty easy to add. I'll think about it this week.