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

chafa question #1509

Closed
Zerogaku opened this issue Nov 24, 2023 · 8 comments
Closed

chafa question #1509

Zerogaku opened this issue Nov 24, 2023 · 8 comments

Comments

@Zerogaku
Copy link

Zerogaku commented Nov 24, 2023

after installing chafa from the git repo, and setting up the previewer (and the previewer script) and sixel in lfrc, i notice that chafa is unable to preview any image, chafa works if i run the command normally on an image in my terminal (foot terminal) but when running it from the preview script, it does not work. chafa from the arch repo works with lf and is able to preview images normally, its just weird that the git repo is unable to work with lf.

@joelim-work
Copy link
Collaborator

lf checks whether the first two bytes of the previewer script output is equal to 1b 50 in order to detect sixel data. The reason why the new version of chafa doesn't work is because it inserts escape sequences at the beginning (I think the reason is to bring the terminal into a consistent state), which means lf will no longer treat the output as sixel data.

It is possible to disable this behavior, just add the --polite on option when calling chafa. Actually polite mode used to be enabled by default until commit hpjansson/chafa@0356373

I have updated the documentation to reflect this. Thanks for reporting.

@Zerogaku
Copy link
Author

Thank you adding --polite on fixed it, one other question, is there a way to get gifs to display properly?

@joelim-work
Copy link
Collaborator

If you mean animating gifs, then I don't think it's possible. The previewer script is supposed to run very quickly and output the preview data (or do whatever is required to display the image) and then terminate, not continuously loop through an animation.

@Zerogaku
Copy link
Author

ah I see thanks, I was wondering why animated gifs could not display when animation was turned on

@hpjansson
Copy link

Hey, apologies for the inconvenience. Looks like I can enable polite mode by default if LF_LEVEL is in the env. Is that the best way to do it?

@joelim-work
Copy link
Collaborator

Hi @hpjansson

Yes, LF_LEVEL is the recommended way to determine whether something is invoked from lf or not. Of course, there's no requirement for you to support this directly in chafa, but if you wish to do so then it would be helpful for users 👍

@hpjansson
Copy link

I think it'd be less work total if we worked around this in Chafa. The alternatives are a) lf parsing past arbitrary control sequences appearing before the image or b) users constantly running into the issue, searching for the solution, and adding it to their rc files. Both of those seem complex/error-prone.

I'm a bit wary of adding lots of exceptions for the various file browsers, but lf seems pretty popular, so... :-)

@joelim-work
Copy link
Collaborator

TBH, I'm equally wary of adding such workarounds directly into the code when the problem can be solved by configuration.

In any case I will keep the reported issue #1582 pinned for a while so that it is easier for users to find.

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

No branches or pull requests

3 participants