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