Skip to content
This repository has been archived by the owner on Jan 15, 2020. It is now read-only.

Fix multiline input #32

Merged
merged 1 commit into from
Apr 16, 2018
Merged

Fix multiline input #32

merged 1 commit into from
Apr 16, 2018

Conversation

kainonergon
Copy link

@kainonergon kainonergon commented Mar 9, 2018

Lemonbar has a bug, that it only reads the first line from input, if lines come fast, for example:

{echo a; echo b} | lemonbar -p

will show "a" and not "b". See
LemonBoy#107

This fix makes lemonbar read all lines from input and show the last one. It is taken from here:
LemonBoy@309047f

@krypt-n
Copy link
Owner

krypt-n commented Apr 16, 2018

Thanks for the PR. Have you tested this a) with your minimal example and b) with a reasonably complex input?

@kainonergon
Copy link
Author

kainonergon commented Apr 16, 2018

Yes, I've tested it. That minimal example shows last line of input as expected. Also I use version of lemonbar-xft with this patch from my fork on daily basis for about a month. I have this panel script with lemonbar so I guess it is complex enough. Works much better with this patch, I don't have to add delays as a workaround for this bug.

EDIT. Only the first commit is needed. Other three were my unsuccessful attempt to fix transparency with xft, so I reverted all changes
EDIT 2. I've squashed all commits into one.

@krypt-n krypt-n merged commit 00a3fe6 into krypt-n:xft-port Apr 16, 2018
@kainonergon
Copy link
Author

This patch also makes lemonbar much faster when it gets a lot of lines without delay. For example here are results from this bash command with the patch:

$ time printf "%s\n" {1..999999}|lemonbar

real	0m1.469s
user	0m0.983s
sys	0m1.271s

and without the patch:

$ time printf "%s\n" {1..999999}|lemonbar

real	1m33.811s
user	0m5.744s
sys	0m5.020s

@cpence
Copy link

cpence commented Apr 18, 2018

For anyone else who shows up confused to this issue, this can cause a problem with some ways of running your lemonbar contents script. If you were previously building your bar with:

echo -ne 'part 1'
echo -ne 'part 2'
...
echo ''

then your bar will no longer work after this patch. You should build your bar contents in a variable and echo them once:

line=''
line+='part 1'
line+='part 2'
...
echo -e $line

No idea why this commit would have caused that, but that's how you fix it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants