GithubHelp home page GithubHelp logo

nikitaivanovv / ctpv Goto Github PK

View Code? Open in Web Editor NEW
258.0 4.0 21.0 2.23 MB

Image previews for lf file manager

Home Page: https://www.nikitaivanov.com/man1/ctpv

License: MIT License

Makefile 2.62% C 86.08% Shell 7.21% Awk 3.37% sed 0.72%
lf preview previewer ueberzug

ctpv's People

Contributors

boscovn avatar harishnkr avatar kalmander avatar nechtarg avatar nikitaivanovv avatar sneethe avatar suhailskhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ctpv's Issues

PDF previews broken by unknown flags

Hi, great program. Really easily makes lf into the best terminal file manager.

PDF image previews aren't working for me due to pdftoppm complaining about flags. I was able to fix it in my case by removing "-tiffcompression jpeg" from "ctvp/sh/prev/pdf.sh".

I'm building it from source on gentoo linux. Anyway, thought I would let you know. Godspeed Ivanov.

support for ueberzugpp?

Looks like ueberzugpp is the successor of ueberzug.
Any way to make ctpv work with ueberzugpp?

Unable to preview office files using libreoffice

Sorry in advance. Maybe I missed something, but is this not supported? Using lf on macos. Libreoffice was installed with homebrew. I do have microsoft Office installed, but i manually set priority to libreoffice in the ctpv config file.

Lf just shows "binary" where preview should be. When I call ctpv in terminal (kitty) to one of these files (docx, pptx, xlsx) I get the following in the attached screenshot

Screen Shot 2023-06-22 at 10 20 54 AM

gifs preview for foot in lf

so basically I added

preview gifs .gif {{
    chafa -f sixel -s "$w"x"$h" "$f"
}}

to my ctpv config
if I type ctpv filename.gif
it will work perfectly but if I try to preview the same gif with lf It will not work

Could you tag another release?

Why

The last tagged release is -right now- 50 commits behind. Using this release is obviously not really ideal, as all the progress from these 50 commits would go to waste.

Why installing from source isn't an option

I use nixos, which makes your OS deterministic, thus directly installing from the tip of your master branch is impossible. That's why we specify the release version directly. Using a release over a commit hash is preferred because it leaves the control to decide which features get packaged by the developer

What I'm asking

Please tag a new release on a stable commit to allows us to package a slightly newer version.

Image previews suddenly stopped working

It now uses exiftool and stoped using ueberzug
I also tried opening lf in kitty but no image preview there too I did'nt change anything it was working fine before
I use archlinux and alacritty in x11(dwm)

error: use of undeclared identifier 'SIG_ERR'

Fail to compile in FreebSD:

doas gmake install

# cc -o src/config.o src/config.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# gmake -C embed
# gmake[1]: Entering directory '/usr/home/wison/temp/ctpv/embed'
# cc     embed.c   -o embed
# gmake[1]: Leaving directory '/usr/home/wison/temp/ctpv/embed'
# mkdir -p gen
# embed/embed -p prev_scr_ sh/prev/any.sh sh/prev/atool.sh sh/prev/audio.sh sh/prev/bat.sh sh/prev/cat.sh sh/prev/colordiff.sh sh/prev/delta.sh sh/prev/diff_so_fancy.sh sh/prev/elinks.sh sh/prev/font.sh sh/prev/gpg.sh sh/prev/highlight.sh sh/prev/image.sh sh/prev/jq.sh sh/prev/libreoffice.sh sh/prev/ls.sh sh/prev/lynx.sh sh/prev/mdcat.sh sh/prev/pdf.sh sh/prev/source_highlight.sh sh/prev/svg.sh sh/prev/symlink.sh sh/prev/torrent.sh sh/prev/video.sh sh/prev/w3m.sh > gen/previews.h
# cc -o src/ctpv.o src/ctpv.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/error.o src/error.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/lexer.o src/lexer.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/preview.o src/preview.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# embed/embed -p scr_ sh/clear.sh sh/end.sh > gen/server.h
# cc -o src/server.o src/server.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# embed/embed -p scr_ sh/helpers.sh > gen/helpers.h
# cc -o src/shell.o src/shell.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/ulist.o src/ulist.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/utils.o src/utils.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# src/utils.c:165:20: warning: implicit declaration of function 'signal' is invalid in C99 [-Wimplicit-function-declaration]
#     ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR);
#                    ^
# src/utils.c:165:44: error: use of undeclared identifier 'SIG_ERR'
#     ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR);
#                                            ^
# 1 warning and 1 error generated.
# gmake: *** [Makefile:55: src/utils.o] Error 1

Then I try search in the whole source files:

rg SIG_ERR

# src/utils.c
# 165:    ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR);

Is it the SIG_ERR defines in OS source code somehow like a constant? or you just miss it ? :)

OS version:

uname -a

# FreeBSD my-bsd 13.1-RELEASE-p3 FreeBSD 13.1-RELEASE-p3 GENERIC amd64

Compilation Error: openssl/md5.h: No such file or directory

I have openssl installed in my machine. And I am not a C dev. Help

make[1]: Leaving directory '/home/thalha/source-installed/ctpv/embed'
cc -O2 -MD -Wall -Wextra -Wno-unused-parameter -c -o src/ctpv.o src/ctpv.c
src/ctpv.c:9:10: fatal error: openssl/md5.h: No such file or directory
9 | #include <openssl/md5.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [: src/ctpv.o] Error 1

User config `PREFIX` rather than system bin

PREFIX := /usr/local

Is there a reason fixing prefix to /usr/bin, or it's possible to be a pass-in option? I would really like it to be a local only program, cause people don't have sudo privilege all the time.

Thanks for the great work!

"Error: The --place option can only be used with a single image, not 2"

Hello,
At first, thank you very much for the project, I used it with the kitty terminal in the lf file manager.
After a certain time, presumably an update, ctpv throws this error (title) after running

ctpv /path/to/image

Note that I don't use any flags and only point to one image.
But when I actually run the flag:

ctpv --place /path/to/image

it throws:

ctpv: invalid option -- '-'

Not working on wsl2

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!

Command "cmd on-quit" doesn't work

Bug: https://mega.nz/file/BNMkULpZ#CkmpOk7YKSsn6PU84T5RisuUouUHp53b2Uzat83cPyw

You should remove the cmd prefix for the new version of lf (r27), otherwise the command will not work

set previewer ctpv
set cleaner ctpvclear
&ctpv -s $id
on-quit $ctpv -e $id

You should also update the documentation in lf -> https://github.com/gokcehan/lf/wiki/Previews#with-stpv-and-ctpv

System
kitty: version 0.25.2 created by Kovid Goyal
lf: version r27
OS: Arch Linux x86_64 5.18.10-zen1-1-zen
WM: sway v1.7

Preview doesn't work on FreeBSD

I've already pasted the following settings (copy from repo README page) to ~/.config/lf/lfrc:

set previewer ctpv
set cleaner ctpvclear
&ctpv -s $id
&ctpvquit $id

But when I open lf (many times to confirm), no image preview:

lf-cannot-preview


So, first thing first, I need to make sure that ueberzug works or not, then I tried to make a draw-image.sh that uses ueberzug to draw an image in the terminal. Here is the script content:

#!/usr/local/bin/bash

[ -z "$5" ] && echo "Usage: $0 <image> <x> <y> <max height> <max width>" && exit

source "`ueberzug library`"

ImageLayer 0< <(
    ImageLayer::add [identifier]="example0" [x]="$2" [y]="$3" [max_width]="$5" [max_height]="$4" [path]="$1"
    read
)

Then run it to see if it works or not:

draw-image.sh ~/Photos/wallpaper/11.jpg 0 0 100 100

And it works perfectly:

ueberzug-can-draw


So, next try is ctpv, here is some commands and output:

ctpv -m ~/Photos/wallpaper/rust_old.png
# .png image/png


# Based on the man page info: ` ctpv file [w] [h] [x] [y] [id]`, I tried to run this command,
# but it prints out the image binary content instead of drawing an image:
ctpv  ~/Photos/wallpaper/rust_old.png 100 100 0 0 

ctpv-cannot-draw


Anything I'm missing?:)

magic.h not found

Could you tell me what package provides this lib? I just got a compile error saying i'm missing this.
I did some searching, but there were several results, including some kernel library.

`ctpv -s` requires Ueberzug?

I got the following error

> ctpv -s 69
cptv: ueberzug not installed

Does it requires ueberzug for running server? I want to use its kitty backend.

Connect ueberzug's stdout to ctpv's stdout

Hello, I've recently started working in a replacement for Ueberzug after its demise. ueberzugpp

It works OOB with ctpv and other software that previously used og ueberzug. But one feature that I added that wasn't in OG Ueberzug doesn't work, that being sixel output.

In ranger, sixel output works with some changes, particularly, connecting ueberzug's stdout to python's.

        self.process = Popen(['ueberzug', 'layer', '--silent'],
                             stderr=PIPE, stdout=sys.stdout.buffer,
                             cwd=self.working_dir,  universal_newlines=True)

(sample of sixel output working on wezterm/sixel)
image

sadly, the same can't be said for lf, as no output is being generated.

image

it works on alacritty/x11
image

One way to fix this is to connect ctpv's (or is this an lf issue?) stdout to ueberzugpp's. I tried to do it on my own but you understand this codebase more than I do.

I'd be grateful if you could make this changes as they would keep compatibility with OG ueberzug and also add support for ueberzugpp.

Better image previews on Wayland

Hi,
lf on wayland uses chafa not ueberzug, thus the preview has low resolution.
Changing the login to Xorg it seems to use ueberzug and preview has good resolution.
But I don't know what software is causing the issue.
Where is the problem? On ueberzug, on wayland, on lf or on ctpv?

No Previews for LF Except Text Files on Gentoo

Hi,

My setup is:
Gentoo 64bit (Multilib) / OpenRC / EloginD / Xorg-Server / Nvidia-Proprietary Drivers / newly built, updated.
Packages from Gentoo Package Manager: Latest versions of ffmpeg, ffmpegthumbnailer, ueberzug, poppler, bat, libreoffice, pdftoppm (also tried installing ueberzug with pip3).
Window Manager: DWM 6.4 (latest git version)
Terminal Emulator: Suckless ST 0.9.0 (latest git version)
LF: Just installed with native single line GO command as in its tutorial (Also tried pre-built binary).
Edited ~/.config/lf/lfrc accordingly for ctpv.
All files are in $PATH.

I can only see text files' previews on lf. Other type of files are seen as "binary". With the same setup on Arch and Artix Linux I could have seen image previews with my own scripts. Now using my own scripts stuck on "loading" where images should be at and I can't even see text previews. With ctpv, there is no "loading" that is stuck but videos, pdfs, images are seen as "binary" files.

I am suspecting if it is related with policy, session management or any type of related stuff, since they are a little bit different in Gentoo as far as I understand. My other configs on lf work as before such as shortcuts, icons and other functions.

Any type of help is appreciated.
Thanks!

`forcekitty` option does not seem to work for me

Hi,

I was trying to make use of your program, however, it seems, that set forcekitty option does not work for me.

I am running Arch, package ctpv-git (installed today, 2022-12-09), kitty version 0.26.5. Kitty method of showing images by itself work (kitty +kitten icat img as well as alias icat img), however, when I don't have any other image previewer installed, ctpv img prints binary garbage at me.

At first, I thought the issue might be ctpv not picking up my config, maybe I put it into wrong location, however, I did a simple test to rule this out - installed chafa, ctpv img started showing images (as it should) and then I changed a line in my config to set noimages and was back to binary garbage - as expected given chafa exists on the system.

Thank you very much for otherwise awesome previewer, it would be great if I was able to make it work.

Btw, I'm running on sway, so ueberzug is not an option, since I'm a full time Wayland resident

cannot preview readme files with glow

Tried to use glow: for markdown previews.
Does not work

config is as follows:

preview glow .md {{
    glow < "$f" 
}}

It works when invoked via command like without lf.
Terminal : kitty

When make install, get error message: "src/ctpv.c:2:10: fatal error: magic.h: No such file or directory"

I cannot install ctpv, because get error message:

$ sudo make install
make -C embed
make[1]: Entering directory '/home/shyciii/ctpv/embed'
make[1]: 'embed' is up to date.
make[1]: Leaving directory '/home/shyciii/ctpv/embed'
cc -o src/ctpv.o src/ctpv.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
src/ctpv.c:2:10: fatal error: magic.h: No such file or directory
2 | #include <magic.h>
| ^~~~~~~~~
compilation terminated.
make: *** [Makefile:55: src/ctpv.o] Error 1

Books in djvu format creates high use of system resources

I have a book in djvu format, when I come over it in lf the memory and CPU utilizations gets very high. Checking top while doing this shows that the program that causes this is magick. So what happens is, ctpv thinks djvu files are image files (which is correct and what file --mime-type says) and tries to process them for a preview with ImageMagick. But since the file is 945 pages, it is of course a huge amount of work for ImageMagick. So I think we should find another method to produce previews for djvu files as they are a common format for (especially old) books.

the album cover is in a terrible place

hello guys. saw some cool snippets in #20, but I have a problem with this one:

preview audio audio/* {{

audio() {
	ffmpegthumbnailer -i "$f" -s 256 -o "$cache_f" 2>/dev/null
}

if exists ffmpeg; then
	x="$(ffmpeg -hide_banner -i "$f" 2>&1)"
	printf '%s\n' "$x"
	y=$((y + $(printf '%s\n' "$x" | wc -l)))
fi

convert_and_show_image audio
}}

image psd

cover position is awful. and there's enough space for it under metadata, so I don't know why cover is not placed there.
I drew the position where I want it to be (square with question mark inside it)
also there's "At least one output file must be specified" in the end of metadata. maybe use ffprobe for metadata gathering?

can't install

08:48:06 alex@alex-xps ctpv ±|master|→ sudo make install
make -C embed
make[1]: Entering directory '/home/alex/ctpv/embed'
make[1]: 'embed' is up to date.
make[1]: Leaving directory '/home/alex/ctpv/embed'
cc -o src/ctpv.o src/ctpv.c -c -O2 -MD -Wall -Wextra -Wno-unused-parameter
src/ctpv.c:2:10: fatal error: magic.h: No such file or directory
2 | #include <magic.h>
| ^~~~~~~~~
compilation terminated.
make: *** [Makefile:55: src/ctpv.o] Error 1

Chafa preview in lf not works

Hello! I am using Hyprland and original lf under Arch .Term is foot.I have followed the README.md and using ctpv in term is normal like this:
2023-04-07_18:04:25

But in lf it is like this:
2023-04-07_18:07:05

Anything i missed?

Text wrap?

Hello, thanks for this great tool!
As lf plugin, on text previews, It would be nice to have some sort of text wrap (or maybe thats a lf thing?)

image

it wraps correctly as standalone though

image

Add dark/black/negative PDF preview

I looked up, and it seems there is no support for dark PDF preview like in stpv:

DARK_DOCS=                # invert documents preview color in image previews

https://github.com/Naheel-Azawy/stpv/blob/5c6058cc4afe289bdcb89bc0eaab84bd1df8f14d/stpv#L282-L286:

    if [ -n "$is_doc" ] && [ -n "$DARK_DOCS" ]; then
        dark_opts='-channel RGB -negate'
    else
        dark_opts=
    fi

https://github.com/Naheel-Azawy/stpv/blob/5c6058cc4afe289bdcb89bc0eaab84bd1df8f14d/stpv#L300-L306:

    # shellcheck disable=SC2086
    convert "${conv_file}[0]"          \
            $dark_opts                 \
            $auto_orient_opts          \
            $max_img_size_opts         \
            -resize ${width}x${height} \
            "$image_cache_path"

I'm not familiar with pdftoppm's options, but it looks like there is no way to invert colors. Maybe it's better to switch to convert instead of pdftoppm for PDF files? Or add a second way to preview PDF files and also set the priority: convert > pdftoppm.

Can't handle files with multiple . in their name

Preview doesn't work with files that have multiple dots in the file name. If I have a file with the name archlinux.ios.torrent the preview will not work but if I rename the same file to archlinux.torrent the preview works fine.

AUR package issue with PGP key

~ ✗  paru -S ctpv-git
:: Resolving dependencies...
:: Calculating conflicts...
:: Calculating inner conflicts...

Aur (1) ctpv-git-r146.2d36fa4-1

:: Proceed to review? [Y/n]:

:: Downloading PKGBUILDs...
 PKGBUILDs up to date
 nothing new to review
fetching devel info...
==> Making package: ctpv-git r146.2d36fa4-1 (Sat 02 Jul 2022 09:24:21 CEST)
==> Retrieving sources...
  -> Updating ctpv git repo...
==> Validating source files with sha512sums...
    ctpv ... Skipped
==> Verifying source file signatures with gpg...
    ctpv git repo ... FAILED (unknown public key 6E656AC5B97B5133)
==> ERROR: One or more PGP signatures could not be verified!
error: failed to download sources for 'ctpv-git-r146.2d36fa4-1':
error: packages failed to build: ctpv-git-r146.2d36fa4-1

"Error: Failed to open controlling terminal with error: input/output error" on kitty terminal

image

This error appears when I launch lf while using ctpv, I'm currently using kitty 0.28.1 and I think this error comes on versions that are higher than kitty 0.26.5 but I'm not 100% sure about it. Also I'm using icat for previews not ueberzug. Also image preview works completely fine but this error message coming up every time I launch lf is annoying and I'm not sure what's causing it to appear. Also I have tested and this error is there when I load kitty without any custom config.

Error Compiling : "src/ctpv.c:2:10: fatal error: magic.h: No such file or directory"

I use Void Linux
I installed libmagic, ImageMagick, ImageMagick-devel
I looked into #23 and I didn't find the packages mentioned there, I'm lost
thanks in advance!

info:
sudo make install
make -C embed
make[1]: Entering directory '/home/zorya/git/ctpv/embed'
make[1]: 'embed' is up to date.
make[1]: Leaving directory '/home/zorya/git/ctpv/embed'
cc -o src/ctpv.o src/ctpv.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
src/ctpv.c:2:10: fatal error: magic.h: No such file or directory
2 | #include <magic.h>
| ^~~~~~~~~
compilation terminated.
make: *** [Makefile:55: src/ctpv.o] Error 1

Feature request: Support imv as an image thumbnail viewer

Hi, I have been using your project with lf and like it very much.

I am wondering if it is possible to add imv as another image thunbnail viewer? I found this project which also uses a terminal image thumbnail previewer. It supports multiple viewers including mpv and imv, so I am wondering if the same can be supported by ctpv.

Not showing preview

I use Debian 12 stable and lf file manager, but the file preview doesnt show. Nothing show. I use st terminal.

Preview values not taken by LF

error shown whenever lf is opened : "preview: value should be empty, 'true', or 'false'"

I am using personal fork of ST if it helps

Note: I tried it on kitty terminal as well, same problem. I dont think its the terminal's problem.

Not using wayland, and the arch signature is not trusted atm

Thanks anyway

Previewing

Cannot get image preview for .svg files.
The script for the svg can be read using ctpv not as a preview but directly from the commandline.
But it cant be previewed inside the file manager (lf in my case).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.