Naheel-Azawy/stpv

How can I use chafa as default previewer rather than kitty?

Closed this issue · 11 comments

Hello I'm currently using lf as my file manager under wayland. lf leads me to this project for image preview. I've installed kitty but I mainly use foot as my default terminal emulator. I also installed chafa and it works in foot. I've added config to lfrc

set previewer stpv
set cleaner stpvimgclr
&stpvimg --listen $id
cmd on-quit $stpvimg --end $id

But this only works in kitty. How can I preview image in foot?

Hello,

I apologize for my extremely late response.
If you just want to use chafa you can add PV_TYPE=text to your config file (e.g. ~/.config/stpv/config.sh).
Does that solves the problem for you?

As of actual images in foot in particular, I haven't used foot before. But it seems that it supports sixel which I'm interested in adding.
But to be honest I'm not too sure when can I get this done.

It only shows image info but not preview the image.
If I just type:

ID=$$
stpvimg --listen $ID &
stpvimg --add $ID myimg.png

it can preview image in foot terminal. Maybe I have something missing in lf config.
BTW, will you add notcurses support? ncls (a tool in notcurses) has better color in my terminal.

It only shows image info but not preview the image. If I just type:

ID=$$
stpvimg --listen $ID &
stpvimg --add $ID myimg.png

it can preview image in foot terminal. Maybe I have something missing in lf config. BTW, will you add notcurses support? ncls (a tool in notcurses) has better color in my terminal.

Have you solved this? I'm facing the same problem.

Hello again,
I wanted to install foot and some wayland DE to try this. But it looks like I forgot to do so... Thanks @GreenAsFuck for the reminder.
Anyway, I just installed GNOME and tried it on foot. Looks like the issue was with isalive(). Should be fixed now.
Please let me know if chafa works fine with you now.
notcurses? Idk, I haven't tried this before will see

This ncls in notcurses doesn't look very nice (left). Am I doing it wrong?
Screenshot from 2022-12-02 22-23-39

Maybe the output quality of ncls is depends on terminal emulator. I've tried it on kitty, foot and wezterm, they perfromed well.

Yeah indeed, ncls seems to be using different methods. For foot, it seems to be using sixel. This brings us back to #31.
chafa supports sixel already. I think something like chafa -f sixel <you-img> should work as good as ncls.
I have just updated stpv. Now you can set PV_TYPE=sixel in your config file and sixel should work. It should work in the sense that if you try stpv <your-img> the image should be displayed.

But this brings another problem to the table. These previewers are made to work inside things like fzf or lf. But from my experience, sixel doesn't work with either of these. There are open issues there
junegunn/fzf#2544
gokcehan/lf#675

There appears to be an interesting discussion on ctpv as well NikitaIvanovV/ctpv#14
As @NikitaIvanovV suggested, this fork of lf should get the job done.
Still not sure what to do with fzf though.

Hello, sorry for bother you again. I've tried both chafa and sixel in foot with lf-sixel fork.
Firstly, I tried with config PV_TYPE=chafa and it fails to run with stpvimg --add $ID 1.jpg (immediately stop with exit code 1)
Then, I tried PV_TYPE=sixel and stpvimg --add $ID 1.jpg goes well, but it doesn't work on lf-sixel.
The good news is that set autochafa in ctpv works for me in lf-sixel.

BTW, I think bc should be listed in dependencies.

Yeah, PV_TYPE=chafa won't do any good. PV_TYPE=sixel is the right option.
Looking at ctpv, I can see what's going on there. Just pushed a new commit. This should work with stpv now.

Here's a screenshot from foot:

Screenshot from 2022-12-09 19-06-50

The good news is that set autochafa in ctpv works for me in lf-sixel.

If you feel comfortable with ctpv that's great

BTW, I think bc should be listed in dependencies.

Good point. I remember at some point in time I had a good reason to use it. But now I can't remember any of that.
Anyway, I think it's better to use timeout from coreutils anyway

Thanks for your patient reply and update. previewer works now.