voidrice/.local/bin/lfub

25 lines
573 B
Text
Raw Permalink Normal View History

2022-03-06 18:19:51 +00:00
#!/bin/sh
# This is a wrapper script for lf that allows it to create image previews with
2022-03-06 18:19:51 +00:00
# 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 "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
mkfifo "$FIFO_UEBERZUG"
ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
exec 3>"$FIFO_UEBERZUG"
2022-03-11 23:32:19 +00:00
trap cleanup HUP INT QUIT TERM PWR EXIT
2022-03-06 18:19:51 +00:00
lf "$@" 3>&-
fi