-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xtitle -s hangs from time to time #422
Comments
I can confirm I'm having the same issue as well. Running NixOS:
Interestingly, it seems to happen when switching tabs in Firefox. My full
Interestingly the Firefox output from
However, other windows don't display doubled output. |
Try the following. However this whole thing is extremely fragile. If blocklet does not write the whole line at once, race condition may occur and parts of the line may get lost. Forever. diff --git a/block.c b/block.c
index c24fb0a..d94ff25 100644
--- a/block.c
+++ b/block.c
@@ -94,18 +94,12 @@ static int block_stdout(struct block *block)
const char *label, *full_text;
int out = block->out[0];
char buf[BUFSIZ];
- size_t count;
int err;
- if (block->interval == INTERVAL_PERSIST)
- count = 1;
- else
- count = -1; /* SIZE_MAX */
-
if (block->format == FORMAT_JSON)
- err = json_read(out, count, block->env);
+ err = json_read(out, -1, block->env);
else
- err = i3bar_read(out, count, block->env);
+ err = i3bar_read(out, -1, block->env);
if (err && err != -EAGAIN)
return err; |
The pull request #425 fixes the issues I had with xtitle |
The PR works indeed, thanks! |
Happens for me too. |
please merge! Works for me too |
Use |
Another workaround (requires python-i3ipc): #!/usr/bin/env python
import i3ipc
def print_window_title(container):
print(container.name if container.name is not None else "", flush=True)
def on_window_focus(i3, e):
print_window_title(e.container)
i3 = i3ipc.Connection()
print_window_title(i3.get_tree().find_focused())
i3.on("window::focus", on_window_focus)
i3.main()
[title]
command=blocks/title
interval=persist |
I've got this in my config and no combination of [active]
command=unbuffer swaymsg -t subscribe -m '["window"]' | jq --unbuffered -r 'select(.change=="focus" or .container.focused == true) | .container.name'
interval=persist It's a shame this repo seems completely abandoned ... |
Yes, as I have said above there is no external workaround for this. If your program produces input faster or slower than And again, it is not because https://github.com/baskerville/xtitle/blob/6f46584fe4ba2763438231e6cce5b180f5ca9c0e/xtitle.c#L212 So every "workaround" that replaces |
Please merge this PR #425 ! Works for me too. |
It seems like #include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int l = 0;
for (;;) {
l++;
fprintf(stderr, "line %d\n", l);
fprintf(stdout, "line %d\n", l);
l++;
fprintf(stderr, "line %d\n", l);
fprintf(stdout, "line %d\n", l);
l++;
fprintf(stderr, "line %d\n", l);
fprintf(stdout, "line %d\n", l);
fflush(stdout);
sleep(3);
}
return 0;
} Here only one signal is sent every 3 lines. The first issue is that we get out of sync between what the block prints and what the bar displays. It may look correct because i3blocks will iterate over the lines and print "line 1", then "line 2", etc., while in fact we may expect to see "line 3", then "line 6", etc. The second issue is that because 3 lines come in, but only one comes out, lines accumulate in the pipe until it eventually gets full (usually 65536 bytes long). Because we write more that we read, we will eventually block on a call to flush after a while. This is the issue encountered in #450 and #451. The workaround for this as of 1.5 is to ensure that the program is line buffered or manually flushes one line at a time, otherwise we may pace its output ourselves for example with That said, the only requirement we have for a block command is to provide newline terminated output, since it is the only reliable boundary that a program can provide to delimit the data to be used. Relying on incomplete lines or when the data is received is simply error prone. @zsugabubus actually had a good guess about draining the output, but the suggested PR has a few concerns so I will push a fix soon. Thanks guys for your patience on the issue! |
i3blocks currently wrongly assumes that a persistent program will be line buffered (or act as such) and flush one line at a time. In this common scenario, it is safe to read a single line per signal, but there are cases where this behavior is not not wanted. For example, a program may print several lines at once, resulting in updating only the first line, while filling up the pipe and eventually have the block program hang on the next write operation. To fix this, drain the pipe of a persistent block upon reception of a signal, but line by line to avoid breaking non JSON blocks. Also make sure to update a block only after having successfully read its output, to avoid resetting a block on error such as on incomplete line, or when the pipe was already flushed. Closes #422 Refs #425
xtitle -s -t 30
runs fine in a terminal, but in i3blocks it will eventually just freeze in some window title and not update itself any longer, requiring i3 to be restarted.Another one is having the same issue: https://www.reddit.com/r/i3wm/comments/fsf26n/xtitle_in_i3blocks_hangs_in_bar/
My config:
[title]
command=xtitle -s -t 30
interval=persist
The text was updated successfully, but these errors were encountered: