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

sixel image preview not working with script but outputs multiple lines of characters when quitting lf #1636

Closed
lukeflo opened this issue Mar 12, 2024 · 4 comments

Comments

@lukeflo
Copy link

lukeflo commented Mar 12, 2024

I know here are multiple issues concerning image preview, but not the exact same outcome.

I use a preview script taken from the wikipage:

case "$(file -Lb --mime-type -- "$1")" in
 ...
 ...
    *text/plain*|*text/x-shellscript*)
        # return false to always repaint, in case terminal size changes
        bat --force-colorization --paging=never --style=changes,numbers \
            --terminal-width $(($2 - 3)) "$1" && false
        ;;
    *image/*)
        chafa -f sixel -s "$2x$3" --animate off --polite on "$1"
        exit 1
        ;;
    *)
        echo "unknown format"
        ;;
esac

My config file is set up with sixel and sourcing the script:

# previewer
set previewer /home/user/.config/lf/previewer.sh
set sixel true

But i get no preview and when I quit lf the terminal is flooded with characters:

2024-03-12_22-00

From inside my terminal the command chafa -f sixel -s 100 --animate off --polite on "file" works fine, also the simple one img2sixel "file".

Maybe I'm missing something obvious, but I've tried out different things. ctpv is also not working correctly when trying to use chafa for unclear reasons (even the patched version). But since it is not as good configurable, I would be happy with the preview script.

My setup:
Manjaro Linux
chafa 1.14
alacritty terminal with sixel support (also not working in wezterm)
lf r31

@vam67423
Copy link

vam67423 commented Apr 9, 2024

I have the same issue, even when using the exact preview script from the lf wiki. All I get is a line of strings like this:

P0;0;0q"1;1;1900;1062#0;2;0;0;0#1;2;5;5;5#2;2;10;10;9#3;2;12;12;12#4;2;14;14;14#5;2;50;5;6#6;2;13;

Used terminal: foot

config:

set previewer ~/.config/lf/sixelPreview.sh

contents of sixelPreview.sh

#!/bin/sh

case "$(file -Lb --mime-type -- "$1")" in
    image/*)
        chafa -f sixel -s "$2x$3" --animate off --polite on "$1"
        exit 1
        ;;
    *)
        cat "$1"
        ;;
esac

I can run chafa just fine outside of lf

@lukeflo
Copy link
Author

lukeflo commented Apr 10, 2024

Since the problems wasn't solved so far, I just switched to fff. It works very similar to lf. And because it is written entirely in bash, it's much easier to modify things by myself.

Thus, I forked the fff repo and implemented a simple file and image preview using sixel which works just good enough for me. Maybe it also satisfies your needs: https://github.com/lukeflo/f3

Maybe someone of the lf guys can still solve the original issue posted here. I, myself, have no experience programming in Go...

@ericmurphyxyz
Copy link

Are you using lfcd? I had the same issue, but solved it by updating to the latest version (r32). (See this thread and #1451.) You may need to build it from source, as not every distribution has packaged the latest version.

@joelim-work
Copy link
Collaborator

@ericmurphyxyz Thanks for the investigation, I can also reproduce with lfcd on version r31. Closing this as the issue has already been fixed.

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

4 participants