kamiyaa / joshuto

ranger-like terminal file manager written in Rust
https://crates.io/crates/joshuto
GNU Lesser General Public License v3.0
3.35k stars 151 forks source link

No image preview on Alacritty in Void Herbstluft #488

Open ktnlikeasmallcat opened 5 months ago

ktnlikeasmallcat commented 5 months ago

Hi there! I hope I'm overlooking something obvious. I'm using joshuto-0.9.6 in alacritty in herbstluftwm on Void Linux kernel 6.6.16_1, and I'm unable to get either ueberzug or ueberzug++ to preview jpg or png images in X11. I compiled U++ with opencv on (just the default flags).

I have libsixel-1.10.3_1 and chafa-1.14.0_1 installed, as well as opencv4-4.6.0_6, opencv-4.6.0_6 (also libopencv for both). Should I pick one instead of having both versions?

I've tested each ueberzug using default configs for joshuto with the other removed (checking using which ueberzug) and I've tried just about every combination of options I can.

j, which is in my $PATH, and ~/.config/joshuto/on_preview_shown & ~/.config/joshuto/on_preview_shown are all executable, and the lines:

preview_shown_hook_script = "~/.config/joshuto/on_preview_shown"
preview_removed_hook_script = "~/.config/joshuto/on_preview_removed"

are under [preview] in joshuto.toml, under the default lines.


Here is a log for ueberzug++ with default options, I'm exiting with q each time, and trying to preview a file in my home directory using the wrapper :

───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: ueberzugpp-ktn.log
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │
   2   │  _   _      _
   3   │ | | | |    | |                                _     _
   4   │ | | | | ___| |__   ___ _ __ _____   _  __ _ _| |_ _| |_
   5   │ | | | |/ _ \ '_ \ / _ \ '__|_  / | | |/ _` |_   _|_   _|
   6   │ | |_| |  __/ |_) |  __/ |   / /| |_| | (_| | |_|   |_|
   7   │  \___/ \___|_.__/ \___|_|  /___|\__,_|\__, |
   8   │                                        __/ |
   9   │                                       |___/     v2.9.2
  10   │ [2024-02-08 20:47:49.263] [terminal] [info] TERM="alacritty", TERM_PROGRAM=""
  11   │ [2024-02-08 20:47:49.265] [terminal] [info] PTY = /dev/pts/1
  12   │ [2024-02-08 20:47:49.270] [X11] [info] Canvas created
  13   │ [2024-02-08 20:47:49.272] [main] [info] Listening for commands on socket /tmp/ueberzugpp-10095.socket
  14   │ [2024-02-08 20:47:54.724] [main] [info] Command received: {"action":"remove","identifier":"preview"}
  15   │ [2024-02-08 20:47:54.916] [main] [info] Exiting ueberzugpp
  16   │ [2024-02-08 20:47:54.923] [main] [error] SIGTERM received, exiting.
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

... with --no-opencv removed from j:

  42   │ [2024-02-08 20:51:17.573] [terminal] [info] TERM="alacritty", TERM_PROGRAM="alacritty"
  43   │ [2024-02-08 20:51:17.575] [terminal] [info] PTY = /dev/pts/4
  44   │ [2024-02-08 20:51:17.580] [X11] [info] Canvas created
  45   │ [2024-02-08 20:51:17.581] [main] [info] Listening for commands on socket /tmp/ueberzugpp-11310.socket
  46   │ [2024-02-08 20:51:23.249] [main] [info] Command received: {"action":"remove","identifier":"preview"}
  47   │ [2024-02-08 20:51:23.434] [main] [info] Exiting ueberzugpp
  48   │ [2024-02-08 20:51:23.441] [main] [error] SIGTERM received, exiting.

... with -o x11. --no-opencv is removed:

  58   │ [2024-02-08 20:53:49.214] [terminal] [info] TERM="alacritty", TERM_PROGRAM=""
  59   │ [2024-02-08 20:53:49.216] [terminal] [info] PTY = /dev/pts/1
  60   │ [2024-02-08 20:53:49.224] [X11] [info] Canvas created
  61   │ [2024-02-08 20:53:49.225] [main] [info] Listening for commands on socket /tmp/ueberzugpp-11976.socket
  62   │ [2024-02-08 20:53:55.299] [main] [info] Command received: {"action":"remove","identifier":"preview"}
  63   │ [2024-02-08 20:53:55.498] [main] [info] Exiting ueberzugpp
  64   │ [2024-02-08 20:53:55.504] [main] [error] SIGTERM received, exiting.

... with -o chafa. --no-opencv is removed:

  74   │ [2024-02-08 20:56:43.009] [terminal] [info] TERM="alacritty", TERM_PROGRAM=""
  75   │ [2024-02-08 20:56:43.011] [terminal] [info] PTY = /dev/pts/1
  76   │ [2024-02-08 20:56:43.021] [main] [info] Listening for commands on socket /tmp/ueberzugpp-12620.socket
  77   │ [2024-02-08 20:56:50.879] [main] [info] Command received: {"action":"remove","identifier":"preview"}
  78   │ [2024-02-08 20:56:50.879] [chafa] [info] Removing image with id preview
  79   │ [2024-02-08 20:56:51.064] [main] [info] Exiting ueberzugpp

I suppose I'm getting the furthest on this last one, but it still doesn't preview. I have the terminal screen-sized.


I'm at a bit of a loss about what to try next. Is this a better issue for ueberzug++? Is there any more info I can provide that might be helpful?

Thanks a lot in advance, and thanks for this great program. I'm doing a fresh install of my OS -- I had it working one the last install with both U and U++, but I've done something wrong this time.

DLFW commented 5 months ago

Hi!

Two thoughts:

  1. The Überzug-logs show “remove”-actions, but no “add”-actions. This smells like the shown-hook is not invoked or does not work
  2. If you're not sure if the Issue is with Joshuto or with Überzug, just use Überzug directly from the shell and try to display an image. If it works, the problem is with the Joshuto configs, otherwise it's an Überzug problem.

Because the “add”-action does not show up in the logs, I would guess the problem is in the Joshuto config. Do you return 0 in the preview-script? (See the “❗Important”-Note in image_previews.md!) Is your max_preview_size there big enough for your image? I set this number to an insane big value, so that the preview is processed for any file. (I think this max_preview_size should actually be removed in Joshuto.)

If this does not lead you to the solution, maybe try to write some log-info from preview_file.sh and on_preview_shown.sh to some temp file (echo "yay" >> /tmp/something) and check if these scripts are actually invoked.

ktnlikeasmallcat commented 5 months ago

Thanks for the guidance. It seems I'm unable to get uz++ showing anything at all using the json syntax on the command line. I might be doing it wrong, I'm using ueberzug layer, hitting enter and pasting {"action": "add", "x": 10, "y": 10, "identifier": "test", "path": "~/Pictures/foo/bar.png"} (I've tested several x,y values). It just hangs, so either I'm inputting the test wrong or something's gone sideways in uz++.

I'm working with some very modestly sized images.

I'd need to do the scripting in https://github.com/kamiyaa/joshuto/issues/366 in order to get that log info, right? It's somewhat dense to me at this moment, I'm having a hard time understanding what precisely would need to be done for that, but I'll revisit it and see if I can't wrap my head around it because the issues there look familiar to what I'm facing.

For now I'm simply using viu -b -w "${PREVIEW_WIDTH}" "${FILE_PATH}" && exit 0 in the preview.sh to create unicode block previews as a stopgap - I may also try to hack together something for getting a preview without block characters.

DLFW commented 5 months ago

Hi again,

for testing if überzug++ works at all (and with which configuration), you may want to use this example wrapper script from überzug++'s repo.

I also had quite some trouble to get it working. Seems there are some pitfalls. I solved my problems by playing around with this img-script. Images in the terminal are always a hack after all. 🙃

Yes, #366 exactly describes the test-logging I was talking about.

Let me try to list out the sequence of stuff that must work and can be tested by you:

If this all works but you still don't have an image, there must be something fishy with the wrapper script or how the show_image is called from the hook.

ktnlikeasmallcat commented 5 months ago

Ueberzug++ is able to display images, according to the wrapper you linked. That I'm able to use viu to preview the image also means that the preview.sh script is also functioning, so the thing that's left for me to do is the second and fourth points here, but how to run those tests more or less escapes me. I appreciate your patience, how do I go about doing those tests exactly? I've copied what's in joshuto.toml's preview area directly, and double checked it corresponds with the paths to the hook scripts.

DLFW commented 4 months ago

Hi! Well, you could start with adding a line

date >> /tmp/on_shown_hook_called.log

at the top of your ~/.config/joshuto/on_preview_shown.

Start Joshuto, move the cursor over some files that yield a text preview, and then check that the log-file has been created. Then just tail -f /tmp/on_shown_hook_called.log in another terminal and move your cursor in Joshuto over some files to preview and check that the hook-script is called for each of them in the log output.

If that does work, remove that line from your hook script and put it into your wrapper-script on the top of your show_image function and check if this function is called.

Let's think further once you're there.

You could also publish your dotfiles somewhere. If somebody has the time, he could have a look. Maybe you just missed the obvious. (Happens to me all the time...)

scotty531 commented 4 months ago

I just fixed what seems to be the same problem. Check that the size and position are set in on_preview_shown and if it still doesn't work check your preview_file for image/*) and point it towards your on_preview_shown. You can debug it with loads of echos like how DLFW suggested.