Krolyxon
Commit e6a46d6

Branches

Refs →

dotfiles-x11.localbinlfub

24 lines · 573 B · Bourne Again Shell (bash)

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
7set -e
8
9cleanup() {
10 exec 3>&-
11 rm "$FIFO_UEBERZUG"
12}
13
14if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
15 lf "$@"
16else
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>&-
24fi