lfub 573 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. # This is a wrapper script for lb that allows it to create image previews with
  3. # ueberzug. This works in concert with the lf configuration file and the
  4. # lf-cleaner script.
  5. set -e
  6. cleanup() {
  7. exec 3>&-
  8. rm "$FIFO_UEBERZUG"
  9. }
  10. if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
  11. lf "$@"
  12. else
  13. [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
  14. export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
  15. mkfifo "$FIFO_UEBERZUG"
  16. ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
  17. exec 3>"$FIFO_UEBERZUG"
  18. trap cleanup HUP INT QUIT TERM PWR EXIT
  19. lf "$@" 3>&-
  20. fi