-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
DietPi-Banner | Word wrap for small terminals #5820
base: dev
Are you sure you want to change the base?
Conversation
Many thanks. Just to assure I understand the logic correctly:
Generally I'm fine with it, looks indeed much better. But let's try to achieve it with a little less external command calls to enhance performance, e.g.:
shellcheck also has some minor complains (only optional tests for best practice). |
Hello, thanks for the review! So the logic is:
Thanks for the bash tips! I will try to reduce the outside call overhead, and run shellcheck. Also: I love this project, it's stable, works flawlessly out of the box, and has greatly enriched my life. However, I've been reading on HN a lot about unwanted PR's from keen contributors who mean well, but ultimately destabilize the code base. If you think this PR is a little bit overkill, or might lead to more headaches in the future, then please don't feel the pressure to merge it. A quick: "thanks, but we like it how it is" is genuinely okay! |
6b16425
to
ac54ef4
Compare
I'll do some benchmarks later via
initial tests via |
Okay, so I've made a few changes:
|
3671fe5
to
943f123
Compare
Roughly doubled execution time on RPi 2 (excluding any download):
There is still room for improvement:
But many thanks for your work on this, I'll definitely merge it for v8.11 release. |
@MichaIng - ah thanks for testing on the RPi2, is there any significant performance hit when
I recall trying this approach but somehow decided that exact matches would be more performant (somehow). Please do feel free to edit, a simple regex makes far more sense in retrospect!
Damn. The pure bash implementation I tried had the same problem, so I thought using a dedicated tool like fmt or fold would solve it cleaner. If the issue is just the MOTD text, then editing the MOTD makes sense to me.
Hah! I thought it looked ugly with 3 indents, and didn't save much linewise. It was much faster though, I remember |
I like the colon wide indentation: This helps to read it better on narrow terminals. On typical wide terminals this seems to have no difference in the output. It looks more "table style". |
482a5fd
to
f136052
Compare
Little performance enhancement with generic control code stripping ( # time for i in {1..10}; do ./dietpi-banner2 1; done > /dev/null
real 0m6.497s
user 0m3.922s
sys 0m3.055s
# time for i in {1..10}; do ./dietpi-banner2 1; done > /dev/null
real 0m6.728s
user 0m3.843s
sys 0m3.391s
# time for i in {1..10}; do ./dietpi-banner3 1; done > /dev/null
real 0m5.633s
user 0m2.950s
sys 0m3.169s
# time for i in {1..10}; do ./dietpi-banner3 1; done > /dev/null
real 0m5.731s
user 0m2.903s
sys 0m3.325s Further enhancements ( # time ./dietpi-banner 1 > /dev/null
real 0m0.315s
user 0m0.200s
sys 0m0.155s
# time ./dietpi-banner 1 > /dev/null
real 0m0.302s
user 0m0.201s
sys 0m0.138s
# time ./dietpi-banner2 1 > /dev/null
real 0m0.669s
user 0m0.427s
sys 0m0.290s
# time ./dietpi-banner2 1 > /dev/null
real 0m0.669s
user 0m0.430s
sys 0m0.289s
# time ./dietpi-banner3 1 > /dev/null
real 0m0.400s
user 0m0.204s
sys 0m0.242s
# time ./dietpi-banner3 1 > /dev/null
real 0m0.401s
user 0m0.261s
sys 0m0.183s Without line breaks enabled: # time ./dietpi-banner 1 > /dev/null
real 0m0.302s
user 0m0.202s
sys 0m0.145s
# time ./dietpi-banner 1 > /dev/null
real 0m0.334s
user 0m0.176s
sys 0m0.197s
# time ./dietpi-banner2 1 > /dev/null
real 0m0.395s
user 0m0.225s
sys 0m0.223s
# time ./dietpi-banner2 1 > /dev/null
real 0m0.419s
user 0m0.214s
sys 0m0.251s
# time ./dietpi-banner3 1 > /dev/null
real 0m0.340s
user 0m0.172s
sys 0m0.205s
# time ./dietpi-banner3 1 > /dev/null
real 0m0.330s
user 0m0.247s
sys 0m0.125s Space wrapping with word wrapping fallback like But there are still some logical and visual issues:
Some can be seen here: I'm not yet sure how to solve these things properly. A Finally, for this to work correctly, I think the whole banner output needs to be aligned to follow strict rules, i.e. consistent title and description colours, or adding the colour codes after the line breaking has been done. |
The last local enhancement on your dietpi-banner3 really seems to be the winner here . As for the folding artefacts you mention, maybe we really do need a custom word wrapping tool that can handle colour-codes and emoticons? I found this implementation dreamed up in awk, but for performance, one could write a small one in C. That would of course create the extra headache of deploying, and maintaining a tool outside the main package manager. One other improvement I thought about was adding a third argument to the Maybe even a 4th parameter, for the desired number of left-padding could be useful. |
f136052
to
97a87a7
Compare
97a87a7
to
d4199ae
Compare
d4199ae
to
657aea9
Compare
During a brief attempt to patch It can also be told to ignore some symbols (hopefully the A quick test shows that
|
It's a Debian package as well, here the man page: https://manpages.debian.org/par |
not faster and doesn't handle whitespace well
It's moving forward: https://gitlab.com/mtekman/print_line |
This PR implements word wrapping functionality in the DietPi-Banner, which helps small terminals format the text better.
Screenshots
105 Columns
33 Columns