aboutsummaryrefslogtreecommitdiff
path: root/.local/share/bin/lf
blob: 430ae0bdeee5cdf238f4b103839e6d6783781fd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
lf=/usr/bin/lf

UB_PID=0
UB_SOCKET=""
UB_PID_FILE="$(mktemp)"

cleanup() {
	exec 3>&-
	ueberzugpp cmd -s "$UB_SOCKET" -a exit
}

# don't try to use ueberzug over ssh
[ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] && exec $lf "$@"

ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PID_FILE" >/dev/null
UB_PID="$(cat "$UB_PID_FILE")"
rm -f "$UB_PID_FILE"
UB_SOCKET="/tmp/ueberzugpp-$UB_PID.socket"
export UB_PID UB_SOCKET
trap cleanup HUP INT QUIT TERM EXIT
$lf "$@" 3>&-