Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add Überzug image support #1172

Closed
dawidpotocki opened this issue Jan 18, 2019 · 15 comments
Closed

Add Überzug image support #1172

dawidpotocki opened this issue Jan 18, 2019 · 15 comments

Comments

@dawidpotocki
Copy link

dawidpotocki commented Jan 18, 2019

Überzug is command line Python3 util which allows to draw images on terminals. In my experience it is more reliable than w3m and works in pretty much any terminal (tested on st, termite, urxvt, kitty, alacritty, gnome-terminal, konsole, lxterminal, xterm).

This is example of simple displaying image using Überzug in bash:

source "`ueberzug library`"

# process substitution example:
ImageLayer 0< <(
    ImageLayer::add [identifier]="example0" [x]="0" [y]="0" [path]="/path/to/image.png"
    read
    ImageLayer::remove [identifier]="example0"
    read
)

So I guess it wouldn't be that hard to implement it?

@dylanaraps
Copy link
Owner

I don't like the idea of sourcing the library. Also it looks like it requires bash 4 due to the associative arrays. Is there not a way of just doing ueberzug img.jpg?

@dawidpotocki
Copy link
Author

dawidpotocki commented Jan 19, 2019

Oh yes, there is. I nearly gave up on searching for it. I loved seeing these useless messages:

Usage:
    ueberzug ROUTINE [options]

Sooo helpful... but whatever, so there is one quick dirty example:

#!/usr/bin/env bash

function ImageLayer {
    ueberzug layer -sp json
}

# ~/ doesn't work
path_to_image="/home/dawidpotocki/.config/wallpaper"
x_padding=0
y_padding=0

function add_image {
	echo "{\"action\": \"add\", \"identifier\": \"image\", \"x\": $x_padding, \"y\": $y_padding, \"path\": \"$path_to_image\"}";
}

ImageLayer -< <(
	add_image
	read
)

There is probably some way to make it more clean, but I'm just too stupid for that :P.

@ShayBox
Copy link

ShayBox commented Jan 24, 2019

Would be great to support a backend that works on all terminals unlike literally every other backend

@hpjansson
Copy link
Contributor

@ShayBox Sorry to butt in here, but -- does Chafa fail on your terminal? It really shouldn't.

@ShayBox
Copy link

ShayBox commented Jan 25, 2019 via email

@dawidpotocki
Copy link
Author

From what I see Chafa is showing images in "ascii", so it isn't really good solution.

@hpjansson
Copy link
Contributor

hpjansson commented Jan 25, 2019

Chafa shows the image in the terminal using terminal characters. w3m and Überzug open a new X11 window on top of the terminal. The flickering in w3m is probably caused by changes in window stacking or some other bug.

That's beside the point, though -- @ShayBox said every backend fails, and I was curious if that included Chafa. If so, they should probably open a separate bug for that as it's designed to work with every terminal, over ssh, etc.

Edit: Thanks for checking, @ShayBox! Sorry again for the noise.

@RaitaroH
Copy link

Thanks to @seebye and @dawidpotocki I got this to work. I will provide a patch (as a txt file cus github). There are 2 issues (though not a big deal, nor I think even possible to fix due to the nature of uberzug itself)

  • you cannot type while uberzug is running
  • if you scroll then the image moves with your scroll
    uberzug.txt

@dawidpotocki
Copy link
Author

dawidpotocki commented Apr 30, 2019 via email

@RaitaroH
Copy link

@dawidpotocki Well I suppose that having uberzug run in the background instead would be better and fix issue 1. Tho I am not so sure where to do that.

@RaitaroH
Copy link

Much more elegant. Thank you @seebye

@dylanaraps
Copy link
Owner

I will look into this. 👍

@ronasimi
Copy link

Has there been any progress on this? The git version of ranger allows you to use ueberzug for image previews, could that code be used in neofetch?

@dylanaraps
Copy link
Owner

I have no interest in this feature whatsoever, however I will accept a pull request adding this functionality to neofetch.

No one other than myself has actually attempted to add support for this backend or asked for my help in doing so.

The main issue I have with Uberzug is the lack of it being able to be run as a one-off command. It needs to run as a daemon and I'm not sure if this model will fit the way images are handled in Neofetch.

I'm open to pull requests and willing to help someone get this merged.

@dylanaraps
Copy link
Owner

As no one seems to want to implement this, discussion can now take place here: #1392

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants