hpjansson / chafa

📺🗿 Terminal graphics for the 21st century.
https://hpjansson.org/chafa/
GNU Lesser General Public License v3.0
2.94k stars 64 forks source link

Chafa version 1.14 breaks image preview on lf #185

Closed Steven79203 closed 2 months ago

Steven79203 commented 9 months ago

After an Arch system update I noticed that chafa stopped working properly on lf. Instead of showing the image it only shows random characters on the preview space. Tested on both foot and alacritty-sixel terminals. After downgrading to 1.12 it started working normally again. Curious though is that if I open an image with chafa on the command line out of the file manager it works normally even on version 1.14. That seems to be a conflict between this new version of chafa and lf.

hpjansson commented 9 months ago

Hi, thanks for reporting this. How is the preview function configured on your lf (i.e. ~/.config/lf/lfrc and any helper scripts)?

Does it help if you add --polite on to the chafa command line?

Failing that, could you attach a screenshot of the broken output?

Steven79203 commented 9 months ago

This is a excerpt from my lfrc:

set autoquit true
set shellopts '-eu'
set ifs "\n"
set scrolloff 10
set icons
set info size
set period 1
set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
set ratios 1:1:2:3
set shell "bash"
set sixel true
set previewer ~/.config/lf/preview

This is the image previewer function in the previewer script

image() {
    geometry="$(($2-2))x$3"
    chafa "$1" -f sixels -s "$geometry" --animate false | fold -w 65535
}

But by adding the '--polite on' option it worked again on version 1.14.

hpjansson commented 9 months ago

Great. Looks like I can detect lf by looking at LF_LEVEL in the env. Polite will be the default under lf in the next release.

veltza commented 9 months ago

Here's why lf doesn't work with --polite off: https://github.com/gokcehan/lf/issues/1509#issuecomment-1826186390