Skip to content
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

swaybar: only show last status line #5103

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

ammgws
Copy link
Contributor

@ammgws ammgws commented Mar 14, 2020

Solves #4496

@ammgws ammgws changed the title [WIP] swaybar: only show last status line swaybar: only show last status line Mar 14, 2020
@ianyfan
Copy link
Contributor

ianyfan commented Mar 14, 2020

Have you tested whether this will work if the last line ends with a new-line character?

@ammgws
Copy link
Contributor Author

ammgws commented Mar 14, 2020

I did before and after these changes, and both output just a new line character. I wasnt sure whether to go further and make it ignore the last line if it's a new line character, or whether the onus is on whatever is generating the status line to not output empty lines.

@ianyfan
Copy link
Contributor

ianyfan commented Mar 14, 2020

I mean: if you send first line\nsecond line\n what does this output?

@ammgws
Copy link
Contributor Author

ammgws commented Mar 15, 2020

From memory it would just output a newline, so the status line would be empty. I will check again once #5106 is fixed.

@ammgws
Copy link
Contributor Author

ammgws commented Mar 16, 2020

In sway config: status_command tail -f /tmp/1
`printf "XXX" >/tmp/1 from my terminal to output to the file, and then running swaybar (killing swaybar in between runs):

XXX new bar output on startup
aaa aaa
aaa\n (empty)
aaa\nbbb bbb
aaa\nbbb\n (empty)

However the second time aaa\nbbb\n or aaa\n is sent, it displays the last value instead of just \n.

Hmm...

@ianyfan
Copy link
Contributor

ianyfan commented Mar 17, 2020

I think that it should show the line before the \n character. However, i3bar seems to try to display all the lines if you send it multiple lines at once, but I'm not sure if we should deviate from its behaviour. We currently, do, since it only the last line is shown, but no-one seems to have complained so far.

@FreeFull
Copy link
Contributor

It is very common to produce output from shell scripts using echo, which by default appends a newline at the end.

As far as i3bar goes, maybe it'd be a good idea to ask the i3 developers if its behaviour is intentional.

@ammgws
Copy link
Contributor Author

ammgws commented Mar 17, 2020

Yeah if no one else does then I will try find some time to install i3 and verify the existing behaviour before asking the guys over there.

@ammgws
Copy link
Contributor Author

ammgws commented Mar 25, 2020

@ianyfan
i3 has confirmed it's a bug, so we can go ahead with our changes.

Testing output of i3/swaybar below. "⏎" means the newline char was printed, but not rendered.

printf "XXX" >/tmp/1 and start i3/sway with bar config of status_command tail -f /tmp/1:

XXX i3 sway sway (this PR)
aaa aaa aaa aaa
aaa\n aaa aaa aaa
aaa\nbbb aaa
bbb
aaa⏎bbb bbb
aaa\nbbb\n aaa
bbb
aaa⏎bbb bbb
aaa\nbbb\n\n todo aaa⏎bbb⏎ bbb
aaa\nbbb\n\n\n todo aaa⏎bbb⏎⏎ bbb

printf "XXX" >>/tmp/1 after i3/swaybar is already running:

XXX i3 sway sway (this PR)
aaa aaa aaa aaa
aaa\n aaa
aaa aaa
aaa\nbbb aaa
bbb
bbb bbb
aaa\nbbb\n aaa
bbb
bbb bbb
aaa\nbbb\n\n todo (blank) (blank)
aaa\nbbb\n\n\n todo (blank) (blank)

@ammgws
Copy link
Contributor Author

ammgws commented Mar 26, 2020

I think I'll need to modify the behaviour of the code around getline to deal with multiple newline characters, then this should be complete.

@ianyfan
Copy link
Contributor

ianyfan commented Mar 26, 2020

I'd prefer to get changes merged into i3 first so that its behaviour can be confirmed (I think we can afford to wait since this seems to be fairly low priority).

Also: could you see what the intended behaviour is if you first send an incomplete line and then complete it later? e.g. if you send aaa followed by bbb\n should it complete the line (show aaabbb) or start a new line (show bbb)

Thanks.

@ammgws
Copy link
Contributor Author

ammgws commented Mar 26, 2020

Good points. Code should be more or less the same so I'll take it over to i3 first.

@ammgws ammgws changed the title swaybar: only show last status line [WIP] swaybar: only show last status line May 14, 2020
@ammgws ammgws marked this pull request as draft May 30, 2020 09:10
@ammgws ammgws changed the title [WIP] swaybar: only show last status line swaybar: only show last status line May 30, 2020
@ammgws
Copy link
Contributor Author

ammgws commented Nov 6, 2020

Closing as don't have time to work on this

Feel free to pick it up

@ammgws ammgws closed this Nov 6, 2020
@ammgws ammgws reopened this Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants