Giter VIP home page Giter VIP logo

lfimg's Introduction

Image preview support for lf (list files) using Überzug

image

lfimg is a repository that contains scripts that are used for generating image preview in lf.
If you want image preview support for vifm, head on over to vifmimg.

Prerequisites

Besides lf and Überzug you will need to install the following packages:

  • ffmpegthumbnailer
  • ImageMagick
  • poppler
  • epub-thumbnailer
  • wkhtmltopdf

The following packages are optional but if installed will provide more functionality to lfimg.

  • bat (optional - color highlight for text files)
  • chafa (optional - for image preview over SSH or inside Wayland session)
  • unzip (optional - for .zip and .jar files)
  • 7z (optional - for .7z files)
  • unrar (optional - for .rar files)
  • catdoc (optional - for .doc files)
  • docx2txt (optional - for .docx files)
  • odt2txt (optional - for .odt and *.ods files)
  • gnumeric (optional - for .xls and .xlsx files)
  • exiftool (optional - for music files)
  • iso-info (optional - for .iso files)
  • transmission (optional - for .torrent files)
  • comicthumb (optional - for .cbz and .cbr files)

Installation

The preferred way of installing lfimg is running make:

make install

If you prefer to do it manually you will need to do the following:

  1. Extract the following files: cleaner, preview to ~/.config/lf/.
  2. Extract lfrun to a directory that is in your $PATH variable (such as /usr/bin or ~/.local/bin).
  3. Edit your lfrc file and add the following lines:
set previewer ~/.config/lf/preview
set cleaner ~/.config/lf/cleaner

Make sure to adjust the previewer and cleaner paths to where you put those scripts in step 2. 4. In order to use lfimg you will need to start lf using the lfrun script.

I recommend that you make an alias in your shell that points to lfrun.
If you are using bash, append the following to your ~/.bashrc:

alias lf=lfrun

Credits

  • lf
  • Seebye's Überzug
  • Brodie's initial preview script which I used as a template for handling the miscellaneous filetypes that this script also handles.

lfimg's People

Contributors

aeblyve avatar alannssantos avatar andonome avatar cbeauhilton avatar dotlambda avatar imgbotapp avatar johndovern avatar mrishu avatar mvrozanti avatar oliverkwebb avatar rafcon-dev avatar roachsinai avatar role92 avatar simonlord avatar sinono3 avatar thimc avatar xevnar avatar xphyro 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  avatar  avatar  avatar

lfimg's Issues

lfrun & quit-on-cd(from lf wiki) not working

I was trying to make the lfrun work with quit-on-cd which mentions a trick to cd to the current directory when quitting.
But for some reason its not working as expected.
If I run regular lf it exits and cds to expected directory but when I do lfrun it doesn't

Minimal ~/.config/lf/lfrc
set cleaner ~/.config/lf/cleaner
set previewer ~/.config/lf/preview
set shell bash
set shellopts '-eu'
set ifs "\n"

cmd quit-and-cd &{{
  pwd > $LF_CD_FILE
  notify-send "quit-and-cd" "$LF_CD_FILE\n$(cat $LF_CD_FILE)"
  lf -remote "send $id quit"
}}
map Q quit-and-cd
Modified ~/.local/bin/lfrun
#!/bin/bash
set -e

cleanup() {
	exec 3>&-
	command rm "$FIFO_UEBERZUG"
}

lf() {
# https://github.com/gokcehan/lf/wiki/Tips#cd-to-current-directory-on-quit
	export LF_CD_FILE=/var/tmp/.lfcd-$$
	command lf $@
	if [ -s "$LF_CD_FILE" ]; then
		local DIR="$(realpath "$(cat "$LF_CD_FILE")")"
		if [ "$DIR" != "$PWD" ]; then
			echo "cd to $DIR"
			cd "$DIR"
		fi
		command rm "$LF_CD_FILE"
	fi
	unset LF_CD_FILE
}

if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
	lf "$@"
else
	[ ! -d "$HOME/.cache/lf" ] && mkdir --parents "$HOME/.cache/lf"
	export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
	mkfifo "$FIFO_UEBERZUG"
	ueberzug layer -s -p json <"$FIFO_UEBERZUG" &
	exec 3>"$FIFO_UEBERZUG"
	# trap cleanup HUP INT QUIT TERM PWR EXIT # Also tried this one
        trap cleanup HUP INT QUIT TERM PWR EXIT
	lf "$@" 3>&-
fi

Image shows as loading

I am running kubuntu. I installed the required packages, and followed the instructions. Despite this the images don't preview and instead have a loading text.
image

seebye/ueberzug is no longer maintained

Hi,

As many of you probably know, the author of Ueberzug, seebye has decided to stop maintaining Ueberzug because of various reasons that I won't go in to here. You're free to read that bit for yourself.

Until there is a maintained fork of Ueberzug, I will stop any development for vifmimg and lfimg as I don't want to maintain anything that relies on projects that no longer receives updates.

I hope that everyone here understands the situation and I just want to thank each and every one of you who contributed.

seebye/ueberzug: https://github.com/seebye/ueberzug/blob/master/README.md

REQUEST: fallback to none/alternate image handler if X forwarding over SSH not possible

Due to the way ueberzug works with X, using this with the lfrun alias causes ueberzug errors to print over the display on a machine where X can't be forwarded.

Is there a way to maybe use chafa as a fallback when this happens? I'm thinking a separate alias to lfrunremote in .profile would do the trick, but I'm not sure how to change the image backend.

Doesnt clean previewed pictures

I'm on Debian 12 with ueberzug and lf. I have 2 problem:

  1. If I move from image to image, it updates the preview image fine, but if I move from image to text file or directory, it no longer deletes the image, but the preview image of the text file/directory appears behind it
  2. There are some images that are displayed upside down in the preview image, even though when I open the image, it displays fine.
    I found that this happens with images where the function below returns a value other than 1:
    identify -format '%[EXIF:Orientation]\n' -- "$file"

Image stay after select new files

Hi,

When i change to new image i can see it without problem.
When i whant to see old image, the old one stay and i can't the the new image.

Same with video preview, when i come back to old video, the last one stay on screen

The last is clear but i can't show image i already see

Ueberzug does not start, the image is shown with chafa only

This is really a nice script, it just does not work for me.
When I run lfrun and visit images, the image is only shown with chafa, not ueberzug.

My setup is basically LARBS from Luke Smith, but some minor changes, like using emacs command type in the terminal
Windows manager is dwm
The Terminal is st. (lfrun does not work with urxvt either on my setup)
I installed ueberzug with pip, it is in /usr/bin.
ranger works without problem with ueberzug (for image previews :-) )

Please let me know what additional information you may need.

can't find config directory

I installed lf from homebrew -> brew install lf and now when check for ~/.config/lf/ the lf is not there I also checked where homebrew install's packages it gave me this location /usr/local/opt/lf/ but here lives only two directories bin/ and share/

what should I do in this case for the following steps:

Extract the following files: cleaner, preview to ~/.config/lf/.
Extract lfrun to a directory that is in your $PATH variable (such as /usr/bin).
Edit your ~/.config/lf/lfrc file and add the following lines:

Audio preview

It would be neat if audio files showed the waves like so
audio

Better previews on Wayland with sixel support

Hi, i've been testing the lfimg and it works perfect out of the box for x but not so much for Wayland (at least in my experience).

I am using foot as my main terminal and i know that some terminals have sixels support (foot being one of them of course), and on Wayland most tools to image preview don't work as good as x.

Is it possible to get sixels support for preview on foot terminal (and maybe some way to generate cache for this protocol)?

Thanks

Edit:

There is this version of ranger with sixels preview support, i don't know if can help for something

https://github.com/3ap/ranger

Sixel support when using chafa

I noticed in #43 it was said Wayland won't be officially supported, however I don't think it will be that hard and chafa may be a more universal solution than ueberzug.
Chafa supports sixel graphics, if you were to run chafa -f sixel foo.jpg you would get a high quality image in your terminal. I tried simply adding this to the preview script, however it doesn't want to work inside of lf. I don't know too much about how lf works or how to debug your script while in lf, I am just hoping there is an easy solution, so that Wayland support isn't something you have to worry about, it should just work.

Problem with ueberzug within neovim

Hi.
I use a plugin to use lf within neovim.
When I open a directory within neovim using lfrun the ueberzug stays on, the previews still displaying in function of the uebezurg lfrun called, which makes the previews located out of place.
Anyone aware of a workaround for this? Be it disabling the ueberzug preview when inside neovim or another method.
image

support for .md markdown files - now works after installing glow

Firstly, I am over the moon with being able to preview images and other documents in lf, thank you for this.

Upate: I am closing this since I installed glow and markdown preview is now working satisfactorily. Furthermore I found that there is already support for glow in lfimg while I did not view the preview script before I posted an issue. If I have further problems, I will open another issue.

image

I edit files in markdown with the md command and while I installed all the add-on and optional add-on programs listed in your documentation no preview appears when I selected a file such as test.md in lf with lfimg installed and where I invoked lfrun.

There are a few possible ways of achieving the preview of markdown files:

UPDATE: I have just discovered GLOW which is terminal based markdown reader (https://github.com/charmbracelet/glow) This might just fit the bill. There is a good video tutorial on integrating glow into lf — https://www.youtube.com/watch?v=EDNpK3iH7A0

  1. View it as plain text files which simply means adding the .md and .markdown extension to the mechanism used presently to preview text files. (I am perfectly content with this as a minimum option.) Extensions used for markdown to be displayed as text are: .md .markdown .mdown .mkd .rst .rmd
  2. Using a utility program to present .md and .markdown extension as a syntax highlighted text file. mdless, mdlint are two such utilities.
  3. Using a utility program to display markdown as a formatted html document. This is probably not possible to implement without invoking a minimalist web browser every time a markdown file is previewed. This would therefore not be a preferred option though I am going to experiment with adding a custom keystroke to my lfrc config to invoke something akin to either 1) bashblog to preview a markdown file in a browser or 2) by using the built-in preview functionality contained in any of the numerous markdown editors floating around.

Crashes lf in st w/ tabbed

There is probably some lower level problem going on here, but after I open st with tabbed -r 2 st -w '', calling lfrun will crash the moment the file browser appears on screen. Tabbed, upon exit, returns the following information:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  18 (X_ChangeProperty)
  Resource id in failed request:  0x3400006
  Serial number of failed request:  2760
  Current serial number in output stream:  2761

Otherwise it works well in st (thank you for that!).

Pixelated-looking previews

Hello,
I'd like to get this project working to spec on my lf. Unfortunately, image previews come out looking kind of pixelated.
pic-selected-210504-0854-52
I get this behavior with both xterm and st, both with the manual and make install methods. My ratios are set to the default.
The bash script on ueberzug's github page does not display images like this.

What might be the problem here? Or is this intended behavior?

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.