Open wisonye opened 1 year ago
Hello! This is weird, it looks like ctpv cannot find ueberzug program installen on the system, so it falls back to the most basic preview, which is plain cat.
What is your /bin/sh shell? Could you please try running command -v "ueberzug" >/dev/null; echo $?
?
Hello! This is weird, it looks like ctpv cannot find ueberzug program installen on the system, so it falls back to the most basic preview, which is plain cat.
What is your /bin/sh shell? Could you please try running
command -v "ueberzug" >/dev/null; echo $?
?
Hey, sorry for late reply, mmh, I use fish
shell and installed uebuerzug
via
FreeBSD pkg
(the standard normal way to install anything in FreeBSD
).
And ueberzug
is in my $PATH
, so I think ctpv
should be able to find it:
N wison | /usr/home/wison which ueberzug
/usr/local/bin/ueberzug
N wison | /usr/home/wison ls -lht /usr/local/bin/ueberzug
lrwxr-xr-x 1 root wheel 12B Dec 11 08:18 /usr/local/bin/ueberzug@ -> ueberzug-3.9
I wison | /usr/home/wison ls -lht /usr/local/bin/ueberzug-3.9
-rwxr-xr-x 1 root wheel 974B Dec 11 08:18 /usr/local/bin/ueberzug-3.9*
I wison | /usr/home/wison ueberzug version
18.1.8
And here is the info of the installed ueberzug
:
I wison | /usr/home/wison pkg info --all | rg ueberzug
py39-ueberzug-18.1.8_1 Draw images on terminals with X11 child windows
I wison | /usr/home/wison pkg info py39-ueberzug
py39-ueberzug-18.1.8_1
Name : py39-ueberzug
Version : 18.1.8_1
Installed on : Fri Dec 16 18:33:10 2022 NZDT
Origin : graphics/py-ueberzug
Architecture : FreeBSD:13:amd64
Prefix : /usr/local
Categories : python graphics
Licenses : GPLv3+
Maintainer : 0mp@FreeBSD.org
WWW : https://github.com/seebye/ueberzug
Comment : Draw images on terminals with X11 child windows
Options :
EXAMPLES : on
Shared Libs required:
libXext.so.6
libX11.so.6
Annotations :
FreeBSD_version: 1301000
flavor : py39
repo_type : binary
repository : FreeBSD
Flat size : 374KiB
Description :
Überzug is a command line util which allows to draw images on terminals by
using child windows.
Advantages to w3mimgdisplay:
- no race conditions as a new window is created to display images
- expose events will be processed,
- so images will be redrawn on switch workspaces
- tmux support (excluding multi pane windows)
- terminals without the WINDOWID environment variable are supported
- chars are used as position - and size unit
- no memory leak (/ unlimited cache)
WWW: https://github.com/seebye/ueberzug
The command you asked me to run, fail in fish
:
I wison | /usr/home/wison command -v "ueberzug" >/dev/null; echo "$?"
fish: $? is not the exit status. In fish, please use $status.
command -v "ueberzug" >/dev/null; echo "$?"
^
I wison | /usr/home/wison command -v "ueberzug" >/dev/null; echo $status
0
Then I gave it a try in bash
shell as well:
[wison@my-bsd /usr/home/wison]$ command -v "ueberzug" >/dev/null; echo $?
0
[wison@my-bsd /usr/home/wison]$ which ueberzug
/usr/local/bin/ueberzug
Plz let me know you still need anything from me:)
Could you please try running ls -l /bin/sh
and /bin/sh -c 'command -v "ueberzug"' >/dev/null; echo $?
Could you please try running
ls -l /bin/sh
and/bin/sh -c 'command -v "ueberzug"' >/dev/null; echo $?
Sure, here it is:
I wison | /usr/home/wison ls -l /bin/sh
-r-xr-xr-x 1 root wheel 169816 May 12 2022 /bin/sh*
I wison | /usr/home/wison /bin/sh -c 'command -v "ueberzug"' >/dev/null; echo $?
fish: $? is not the exit status. In fish, please use $status.
/bin/sh -c 'command -v "ueberzug"' >/dev/null; echo $?
^
I wison | /usr/home/wison /bin/sh -c 'command -v "ueberzug"' >/dev/null; echo $status
0
# Then run that in `/bin/sh`:
I wison | /usr/home/wison sh
$ /bin/sh -c 'command -v "ueberzug"' >/dev/null; echo $?
0
How did you make fish your default shell?
I'm pretty sure it has something to do with fish being the default shell on your system. Although I might be wrong since /bin/sh
seems to be working as expected...
How did you make fish your default shell?
Fish is not a POSIX shell, while ctpv expects a POSIX shell to be running because all its internal preview scripts are written in POSIX shell syntax. Do you have bash installed on your system?
Fish is not a POSIX shell, while ctpv expects a POSIX shell to be running because all its internal preview scripts are written in POSIX shell syntax. Do you have bash installed on your system?
Sorry for late reply, yes I understand and yes I got Bash
installed. If I insist to stay with Fish
(as that's my favourite shell), is there any handy and easy way that I can run your plugin in bash
session? (I mean how to use a script command to replace the default settings in lfrc
?)☺️
I can add a config option to specify shell path. So in your case you could specify a path to bash.
Just added shell
option (6f364cf383e87d2ab51bee307bbd149c2fb252db). Try adding set shell "/usr/bin/bash"
in your ctpv config.
Just added
shell
option (6f364cf). Try addingset shell "/usr/bin/bash"
in your ctpv config.
I git clone
the latest version and confirmed that with your last commit, but it can't compile :(
Does anything change in the Makefile
(as I remember I can compile before)....
doas make install
Password:
cc -o ctpv -O2 -pipe
cc: error: no input files
*** Error code 1
Stop.
make: stopped in /usr/home/wison/temp/ctpv
I wison | /usr/home/wison/temp/ctpv cc --version
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
Target: x86_64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /usr/bin
Last time I changed the Makefile was on October 10, So it's probably unrelated to that. It looks like Makefile does not have a list of source files. What kind of make
utility do you use? Is it GNU Make? I think you can check with make --version
.
Last time I changed the Makefile was on October 10, So it's probably unrelated to that. It looks like Makefile does not have a list of source files. What kind of
make
utility do you use? Is it GNU Make? I think you can check withmake --version
.
Ok, I fixed the make
issue by installing gmake
and doas gmake install
works, but it seems still does not solve the problem:) I've already added the shell
setting to the config file. lf
still no image preview, no matter I open lf
in fish
or bash
:)
I think you need to know the following information (re-run the previous commands you wanted me to do):
I wison | /usr/home/wison /usr/local/bin/bash --version
GNU bash, version 5.2.15(0)-release (amd64-portbld-freebsd14.0)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
I wison | /usr/home/wison
I wison | /usr/home/wison bash
[wison@my-bsd /usr/home/wison]$
[wison@my-bsd /usr/home/wison]$ command -v "ueberzug" >/dev/null; echo "$?"
0
[wison@my-bsd /usr/home/wison]$ which ueberzug
/usr/local/bin/ueberzug
[wison@my-bsd /usr/home/wison]$ ueberzug version
18.1.8
[wison@my-bsd /usr/home/wison]$ bat ~/.config/ctpv/config
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: /home/wison/.config/ctpv/config
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ set shell "/usr/local/bin/bash"
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[wison@my-bsd /usr/home/wison]$ ctpv -m ~/Photos/wallpaper/rust_old.png
.png image/png
But when I run ctpv ~/Photos/wallpaper/rust_old.png 100 100 0 0
, it still print out the image data to the console which means not ok:)
Also, I found one more thing: It seems the ctpv
server doesn't exit automatically??? As every time I open a new lf
instance, it creates new ctpv
server and won't kill it even lf
quits:
#
# I open 4 `lf` instances and navigate to some image files,
# then quit the `lf` (all of them), but all `ctpv` servers are still there
#
/bin/ps aux | rg ctpv
wison 78956 0.0 0.0 13472 3276 3 I+ 19:54 0:00.01 /bin/sh /usr/bin/man ctpv
wison 39698 0.0 0.1 57396 33428 1 I+ 19:53 0:00.51 nvim /home/wison/temp/ctpv/src/config.c
wison 32946 0.0 0.0 16484 5592 6 S 20:19 0:00.01 ctpv -s 32841
wison 55239 0.0 0.0 16484 5592 6 S 20:20 0:00.01 ctpv -s 55121
wison 67168 0.0 0.0 16484 5596 6 S 20:20 0:00.00 ctpv -s 67138
wison 81413 0.0 0.0 9980 6220 6 R+ 20:20 0:00.00 rg ctpv
wison 85427 0.0 0.0 16484 5596 6 S 20:19 0:00.01 ctpv -s 85293
Could you please send your ctpv config here?
Could you please send your ctpv config here?
Sure, it just one line:
set shell "/usr/local/bin/bash"
I've added -d
option for debug messages. Could you please try running ctpv on an image and print the output here?
ctpv ~/Photos/wallpaper/rust_old.png 100 100 0 0
Ok, I pull and recompiled and reinstalled, here is what you want I think:
Try to preview a file:
I wison | /usr/home/wison/temp/ctpv ctpv -d ~/Photos/wallpaper/rust_old.png 100 100 0 0 > ~/temp/ctpv_debug.log
# Running preview: image
# Preview image failed
# Running preview: any
#
# Compare the log file size and original image size,
# I opened the log file, it seems just the image binary data.
#
I wison | /usr/home/wison/temp/ctpv ls -lht ~/temp/ctpv_debug.log
# -rw-r--r-- 1 wison wison 8.8M Apr 11 11:04 /home/wison/temp/ctpv_debug.log
I wison | /usr/home/wison/temp/ctpv ls -lht ~/Photos/wallpaper/rust_color.png
# -rwx------ 1 wison wison 1.1M Jan 6 18:04 /home/wison/Photos/wallpaper/rust_color.png*
Run in lf
:
I changed my lf
config:
# Add debug flag and output to log file
&ctpv -d -s $id >> ~/temp/lf_ctpv.log
&ctpvquit $id >> ~/temp/lf_ctpvquit.log
Then run lf
and navigate to a few image files, nothing happen and there is no log content:
N wison | /home/wison/temp /bin/ps aux | rg ctpv
# wison 23037 0.0 0.0 16484 5588 2 S 11:09 0:00.01 ctpv -s 22342
# wison 92911 0.0 0.0 16484 5592 2 S 11:10 0:00.01 ctpv -d -s 92010
# wison 38032 0.0 0.0 18176 6472 3 R+ 11:11 0:00.00 rg ctpv
I wison | /home/wison/temp ls -lht ~/temp/lf*.log
# -rw-r--r-- 1 wison wison 0B Apr 11 11:10 /home/wison/temp/lf_ctpvquit.log
# -rw-r--r-- 1 wison wison 0B Apr 11 11:10 /home/wison/temp/lf_ctpv.log
And it seems to treat the image file as a binary
file type or maybe fallback to bat/cat
?
I've already pasted the following settings (copy from repo README page) to
~/.config/lf/lfrc
:But when I open
lf
(many times to confirm), no image preview:So, first thing first, I need to make sure that
ueberzug
works or not, then I tried to make adraw-image.sh
that usesueberzug
to draw an image in the terminal. Here is the script content:Then run it to see if it works or not:
And it works perfectly:
So, next try is
ctpv
, here is some commands and output:Anything I'm missing?:)