jaor / xmobar

A minimalistic status bar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output to terminal

p4vook opened this issue · comments

Is it possible to output statusline to stdout using escape color sequences?
That would allow using xmobar inside wayland.

commented

I was thinking about status_command in waybar, just like i3status, but not quite i3status :)

I've looked at the sources for 10 minutes and I wasn't able to trace the actual rendering to "text" (probably some markup type) process.

commented

i've created a new branch named text and implemented there basic text
output to stdout. it doesn't support colours yet, but the basics are
there. it also simply concatenates the left, center and right
segments; with a textOutputWidth configuration parameter it shouldn't
be difficult to add some aligment too, but not sure how useful that is
in this case. to make xmobar output to stdout, one just either passes
the flag -T to its invocation, or sets textOutput=True in the
configuration file.

I've checked out text branch. In general, it works :), but sway fails to update the status line, I'm trying to debug this issue. It seems like it has some trouble reading from xmobar.
Please read https://manpages.debian.org/testing/sway/swaybar-protocol.7.en.html. This is a JSON-based protocol for status bar, used initially for i3bar and now, with some changes listed in the man page, for swaybar.
I still think that terminal output is useful, but it seems that Sway does not render escape sequences. Swaybar-protocol also allows for some features like clicking support.

Looks like the problem is that swaybar is chunking data in 8192-byte blocks and then processing it all. I will continue debugging this problem.

commented

I know that's not the real fix, but replacing xmobar -T with unbuffer xmobar -T makes the buffering problem disappear.

@jaor no, that does not work: "escape" in waybar escapes only pango markup, not ANSI escape symbols.

The buffering problem still persists and I even managed to create simple reproducible test for it:
echo "" | xmobar -T | cat buffers in batches of 8192 bytes.

I've found a fix to buffering: just set line-buffering in startTextLoop.
buffering-fix.patch.txt

commented
commented

On Sat, Jan 29 2022, Pavel Kalugin wrote: @jaor no, that does not work: "escape" in waybar escapes only pango markup, not ANSI escape symbols.
oh, that's unfortunate :(

I've implemented pango markup and created a pull request (#603).
Please run autoformatter if you merge it, I don't have one.

commented