1
0
Fork 0

ueberzugpp is kind of trash, I didn't realize ueberzug has a continuation elsewhere

This commit is contained in:
Luca Bilke 2023-06-13 19:35:02 +02:00
parent deb6905263
commit 11a76e35f1
3 changed files with 16 additions and 15 deletions

View file

@ -1,3 +1,5 @@
#!/bin/sh
# kitty +kitten icat --clear --silent --stdin no --transfer-mode memory >/dev/tty
ueberzugpp cmd -s "$UB_SOCKET" -a remove -i PREVIEW
if [ -n "$FIFO_UEBERZUG" ]; then
printf '{"action": "remove", "identifier": "PREVIEW"}\n' > "$FIFO_UEBERZUG"
fi

View file

@ -1,14 +1,18 @@
#!/bin/sh
set -C -f
image() {
f=$1
w=$2
h=$3
x=$4
y=$5
# kitty +kitten icat --clear --stdin no --silent --transfer-mode memory --place "${w}x${h}@${x}x${y}" "$f" >/dev/tty && exit 1
# chafa "$f" -f symbols -s "$((w-2))x$h" && exit 1
ueberzugpp cmd -s "$UB_SOCKET" -a add -i PREVIEW -x "$x" -y "$y" --max-width $(($2-1)) --max-height "$h" -f "$f" && exit 1
printf "%b" "\033[31mImage previewer failed\033[0m\n"
# kitty +kitten icat --clear --stdin no --silent --transfer-mode memory --place "${w}x${h}@${x}x${y}" "$f" >/dev/tty
if [ -f "$1" ] && [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1; then
printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$4" "$5" "$(($2-1))" "$(($3-1))" "$1" > "$FIFO_UEBERZUG"
fi
exit 1
}

View file

@ -2,24 +2,19 @@
set -e
UB_PID=0
UB_SOCKET=""
UB_PIDFILE="/tmp/ubpid.$(uuidgen)"
clean () {
exec 3>&-
ueberzugpp cmd -s "$UB_SOCKET" -a exit
rm "$FIFO_UEBERZUG"
}
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
command lf "$@"
else
[ ! -d "$XDG_CACHE_HOME/lf" ] && mkdir --parents "$XDG_CACHE_HOME/lf"
ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PIDFILE"
UB_PID=$(cat "$UB_PIDFILE")
UB_SOCKET="/tmp/ueberzugpp-${UB_PID}.socket"
rm "$UB_PIDFILE"
export UB_PID UB_SOCKET
export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
mkfifo "$FIFO_UEBERZUG"
ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
exec 3>"$FIFO_UEBERZUG"
trap clean HUP INT QUIT TERM PWR EXIT
command lf "$@" 3>&-
fi