gokcehan/lf

Chafa works fine out of lf but not working properly in previews

Closed this issue · 2 comments

This is my lfrc

set sixel true
set previewer /home/fexxix/.config/lf/pv.sh

My preview script

#!/bin/sh

echo "Previewing file: $1"

case "$(file -Lb --mime-type -- "$1")" in
    image/*)
        echo "Converting image to Sixel"
        chafa -f sixel -s "$2x$3" --animate off --polite on "$1"
        exit 1
        ;;
    *)
        echo "Not an image file, displaying as text"
        cat "$1"
        ;;
esac

Chafa in terminal without lf

Screenshot from 2024-02-07 23-13-12

Chafa with lf

Screenshot from 2024-02-07 23-15-56

Distribution: Fedora 39
Terminal: Foot
Linux-kernel: 6.6.14-200.fc39.x86_64

Edit: It might be related to #1582 but notice that i have polite --on in my script already.

Edit 2: No it's prolly not, my current chafa version is 1.10.3

Edit 3: I updated my chafa to 1.15.0 and the issue still the same.

It seems to be the echo lines, I see the same output you do with your script as written and with this script it previews images successfully.

#!/bin/sh

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

It seems to be the echo lines, I see the same output you do with your script as written and with this script it previews images successfully.

#!/bin/sh

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

BRUH. I added those lines for debugging purposes, but it was the problem. Initially, I copied the script directly from the docs and that had an echo in it too. They should remove that.