From 0e2d387565cb03c41cef33b9ff01eac5a5cb9132 Mon Sep 17 00:00:00 2001 From: marcellus Date: Thu, 14 Sep 2023 22:26:17 +0200 Subject: update: general changes, read the diff --- scripts/lfub | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 scripts/lfub (limited to 'scripts/lfub') diff --git a/scripts/lfub b/scripts/lfub new file mode 100755 index 0000000..0d8b7fe --- /dev/null +++ b/scripts/lfub @@ -0,0 +1,23 @@ +#!/bin/sh +# This is a wrapper script for lf that allows it to create image previews with +# ueberzug. This works in concert with the lf configuration file and the +# lf-cleaner script. + +set -e + +cleanup() { + exec 3>&- + rm "$FIFO_UEBERZUG" +} + +if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + lf "$@" +else + [ ! -d "$XDG_CACHE_HOME/lf" ] && mkdir -p "$XDG_CACHE_HOME/lf" + export FIFO_UEBERZUG="$XDG_CACHE_HOME/lf/ueberzug-$$" + mkfifo "$FIFO_UEBERZUG" + ueberzug layer -s <"$FIFO_UEBERZUG" -p json & + exec 3>"$FIFO_UEBERZUG" + trap cleanup HUP INT QUIT TERM PWR EXIT + lf "$@" 3>&- +fi -- cgit v1.2.3