NikitaIvanovV / ctpv

Image previews for lf file manager
https://www.nikitaivanov.com/man1/ctpv
MIT License
264 stars 24 forks source link

Not working on wsl2 #3

Closed huibosa closed 2 years ago

huibosa commented 2 years ago

I've installed ctpv on wsl2, and follow your setup guide, but seems It's not working on wsl2.

So is it a bug, or the wsl2 hasn't been support yet?

Thank you for your work!

NikitaIvanovV commented 2 years ago

I cannot test it on WSL2 but I believe it should work there. What do you mean by "not working"? All the previews don't show up? You can try running ctpv <file> and see if there are any error messages.

huibosa commented 2 years ago

I cannot test it on WSL2 but I believe it should work there. What do you mean by "not working"? All the previews don't show up? You can try running ctpv <file> and see if there are any error messages.

NikitaIvanovV commented 2 years ago

If you run the command manually and it works, it means you just need to install more programs to enable the previews. You can find the list in the manual or README under Dependencies section.

huibosa commented 2 years ago

If you run the command manually and it works, it means you just need to install more programs to enable the previews. You can find the list in the manual or README under Dependencies section.

But I'm sure to have ueberzug and pdftoppm installed already.

NikitaIvanovV commented 2 years ago

Could you try installing exiftool and see if it works?

huibosa commented 2 years ago

Could you try installing exiftool and see if it works?

It successfully gives the metadata of png files and pdf in lf, seems there's some problem only concern about the image render?

NikitaIvanovV commented 2 years ago

Yeah, seems like it. Are you sure that ueberzug supports WSL2? I think you can run ueberzug layer and see if it produces any errors.

huibosa commented 2 years ago

Yeah, seems like it. Are you sure that ueberzug supports WSL2? I think you can run ueberzug layer and see if it produces any errors.

The output:

Traceback (most recent call last):
  File "/home/huibosa/.local/bin/ueberzug", line 8, in <module>
    sys.exit(main())
  File "/home/huibosa/.local/lib/python3.10/site-packages/ueberzug/__main__.py", line 55, in main
    module.main(options)
  File "/home/huibosa/.local/lib/python3.10/site-packages/ueberzug/layer.py", line 206, in main
    window_infos = xutil.get_parent_window_infos()
  File "/home/huibosa/.local/lib/python3.10/site-packages/ueberzug/xutil.py", line 171, in get_parent_window_infos
    pid_window_id_map = get_pid_window_id_map()
  File "/home/huibosa/.local/lib/python3.10/site-packages/ueberzug/xutil.py", line 99, in get_pid_window_id_map
    .value)
AttributeError: 'NoneType' object has no attribute 'value'

I've searched "ueberzug + wsl" this on google, but not find any useful messages.

Is ueberzug the only method to preview images for ctpv? I've seen some other software using w3m to preview.

NikitaIvanovV commented 2 years ago

Right now there two methods: ueberzug and kitty terminal. w3m is really buggy so I don't know if it's a good idea to add support for it (also, I suspect it won't work too).

What I could add support for is chafa. It converts images to characters a terminal can display, which results in poorer image quality but at least it will work on WSL2.

huibosa commented 2 years ago

Right now there two methods: ueberzug and kitty terminal. w3m is really buggy so I don't know if it's a good idea to add support for it (also, I suspect it won't work too).

What I could add support for is chafa. It converts images to characters a terminal can display, which results in poorer image quality but at least it will work on WSL2.

I'm afraid kitty does not support on windows, unless running in wsl, which will give poor performance.

Anyway, thank you for your help, it would be nice if you could add support for chafa

NikitaIvanovV commented 2 years ago

Added support for chafa! Please try installing it and see if it works. (And make sure to uninstall Ueberzug.)

huibosa commented 2 years ago

Added support for chafa! Please try installing it and see if it works. (And make sure to uninstall Ueberzug.)

Seems not working, output:

chafa: Unknown option --animate
NikitaIvanovV commented 2 years ago

What version of chafa do you have?

huibosa commented 2 years ago

What version of chafa do you have?

NikitaIvanovV commented 2 years ago

I've remove the --animate option. It was used to display gifs properly. Now I use convert (Image Magick) instead.

huibosa commented 2 years ago

I've remove the --animate option. It was used to display gifs properly. Now I use convert (Image Magick) instead.

It worked now, both for gif and png file, thank you for your work!

Any here's another problem which only occurs in wsl, I don't konw if I should open another issue:

If I directly run sudo make install, the compiler will give the output:

cc -lmagic -lcrypto src/config.o src/ctpv.o src/error.o src/lexer.o src/preview.o src/server.o src/shell.o src/ulist.o src/utils.o src/vector.o -o ctpv
/usr/bin/ld: src/ctpv.o: in function `init_magic':
ctpv.c:(.text+0x1aa): undefined reference to `magic_open'
/usr/bin/ld: ctpv.c:(.text+0x1c0): undefined reference to `magic_load'
/usr/bin/ld: ctpv.c:(.text+0x1d1): undefined reference to `magic_error'
/usr/bin/ld: ctpv.c:(.text+0x208): undefined reference to `magic_error'
/usr/bin/ld: src/ctpv.o: in function `preview':
ctpv.c:(.text+0x6ca): undefined reference to `magic_file'
/usr/bin/ld: ctpv.c:(.text+0x7f4): undefined reference to `MD5'
/usr/bin/ld: ctpv.c:(.text+0x921): undefined reference to `magic_error'
/usr/bin/ld: src/ctpv.o: in function `mime':
ctpv.c:(.text+0xadb): undefined reference to `magic_file'
/usr/bin/ld: ctpv.c:(.text+0xb9d): undefined reference to `magic_error'
/usr/bin/ld: src/ctpv.o: in function `main':
ctpv.c:(.text.startup+0x184): undefined reference to `magic_close'
collect2: error: ld returned 1 exit status
make: *** [Makefile:45: ctpv] Error 1

I know it's a linker error, so every time I have to change line 45 in Makefile:

$(CC) $(LDFLAGS) $+ -o $@

to:

$(CC) $+ -o $@ $(LDFLAGS)

This problem only happens in wsl, when I'm use my arch machine, all work well without change the Makefile.

NikitaIvanovV commented 2 years ago

You just change the order of arguments and it works? Do you have any ideas why it might happen?

huibosa commented 2 years ago

You just change the order of arguments and it works? Do you have any idea why it happens?

NikitaIvanovV commented 2 years ago

Thank you! It's weird because I use Arch too and I did not have any issue. I've changed the order of arguments, could you please test if it works?

huibosa commented 2 years ago

Thank you! It's weird because I use Arch too and I did not have any issue. I've changed the order of arguments, could you please test if it works?

It's all ok now