Closed frnogueira closed 2 years ago
Hi! I suppose you want to use ueberzug previewes in addition to your existing lf configuration (because this lf-ueberzug gadget really is good for nothing but to demonstrate ueberzug previews). To achieve that you simply
set previewer lf-ueberzug-previewer
set cleaner lf-ueberzug-cleaner
Add the following to your .zshrc
lf-ueberzug() {
cleanup() {
lf-ueberzug-cleaner
kill "$UEBERZUGPID"
pkill -f "tail -f $LF_UEBERZUG_TEMPDIR/fifo"
rm -rf "$LF_UEBERZUG_TEMPDIR"
}
trap cleanup INT HUP
# Set up temporary directory.
export LF_UEBERZUG_TEMPDIR="$(mktemp -d -t lf-ueberzug-XXXXXX)"
# Launch ueberzug.
mkfifo "$LF_UEBERZUG_TEMPDIR/fifo"
tail -f "$LF_UEBERZUG_TEMPDIR/fifo" | ueberzug layer --silent &
UEBERZUGPID=$!
lf "$@"
cleanup
}
alias lf=lf-ueberzug
Does this answer your question?
I'm having a similar issue to op. I followed your instructions and added to the .zshrc, but no image previews still. I get this after closing lf
$ lf
[2] 4970 4971
removed '/tmp/lf-ueberzug-HI3Rw0/fifo'
removed directory '/tmp/lf-ueberzug-HI3Rw0'
$
[2] + terminated tail -f "$LF_UEBERZUG_TEMPDIR/fifo" |
done ueberzug layer --silent
Does this only work with specific terminals? I'm using suckless' st.
Does this only work with specific terminals? I'm using suckless' st.
Hi @Skrib. It's supposed to be terminal-agnostic and I'm also using st.
Let's check a few other things (some of the answers can be deduced from the fact that you use st, but let's make sure we're on the same page :wink:)
ueberzug version
?Do ueberzug previews work in principle on your machine? This snippet should generate an overview inside the terminal if run by zsh or bash.
# Fetch image
imgurl="https://upload.wikimedia.org/wikipedia/commons/3/33/Blue_merle_koolie_short_coat_heading_sheep.jpg"
tmpdir="$(mktemp -d)"
cd "$tmpdir"
curl -Lso - "$imgurl" > dog.jpg
# Start ueberzug daemon
mkfifo ueberzug_fifo
tail -f ueberzug_fifo | ueberzug layer -p json &
# Create an overlay
cat <<<'{ "action": "add", "identifier": "ueberzug-preview", "path": "dog.jpg", "x": 0, "y": 0, "width": 20, "height": 16, "scaler": "contain" }' >ueberzug_fifo
Thanks for the response, but I've got it working now.
I had to reinstall Linux because of some driver issues. When I tried implementing your first post in this thread again, I wasn't getting any errors, it just wasn't working. But commenting this line I had in lfrc fixed it:
# Vars that depend on environmental variables
$lf -remote "send $id set previewer ${XDG_CONFIG_HOME:-$HOME/.config}/lf/scope"
I'm assuming the original errors were from my poor implementing of some other lf code.
Sorry for the hassle and thanks agian! This works great now and is very useful.
Hi! lf-ueberzug only work in the git directory. When I put the files in /usr/bin, create the alias in .zshrc, the lf-ueberzug not using the lfrc file, and the previews not working. What the solution for this? Thanks!