Added ueberzugpp to lf
This commit is contained in:
parent
613c97cee8
commit
fc2e67675d
4 changed files with 50 additions and 40 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
if [ -n "$FIFO_UEBERZUG" ]; then
|
|
||||||
printf '{"action": "remove", "identifier": "PREVIEW"}\n' > "$FIFO_UEBERZUG"
|
ueberzugpp cmd -s $UB_SOCKET -a remove -i PREVIEW
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,27 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
CACHE="$HOME/.cache/lf/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' \
|
|
||||||
-- "$(readlink -f "$1")" | sha256sum | awk '{print $1}'))"
|
|
||||||
|
|
||||||
image() {
|
image() {
|
||||||
# if [ -n "$DISPLAY" ]; then
|
FILE_PATH="$1"
|
||||||
# printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y":"%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' \
|
X=$4
|
||||||
# "$4" "$5" "$(($2-1))" "$(($3-1))" "$1" > "$FIFO_UEBERZUG"
|
Y=$5
|
||||||
# exit 1
|
MW=$(($2 - 1))
|
||||||
# else
|
MH=$3
|
||||||
chafa "$1" -s "$4x"
|
ueberzugpp cmd -s "$UB_SOCKET" -a add -i PREVIEW -x "$X" -y "$Y" --max-width "$MW" --max-height "$MH" -f "$FILE_PATH"
|
||||||
# fi
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
batorcat() {
|
batorcat() {
|
||||||
file="$1"
|
file="$1"
|
||||||
shift
|
shift
|
||||||
if command -v bat > /dev/null 2>&1
|
if command -v bat >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
bat --color=always --style=plain --pager=never "$file" "$@"
|
bat --color=always --style=plain --pager=never "$file" "$@"
|
||||||
else
|
else
|
||||||
cat "$file"
|
cat "$file"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CACHE="$HOME/.cache/lf/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}'))"
|
||||||
|
|
||||||
case "$(file --dereference --brief --mime-type -- "$1")" in
|
case "$(file --dereference --brief --mime-type -- "$1")" in
|
||||||
image/*)
|
image/*)
|
||||||
image "$1" "$2" "$3" "$4" "$5" "$1"
|
image "$1" "$2" "$3" "$4" "$5" "$1"
|
||||||
|
|
|
||||||
32
.local/bin/lf
Executable file
32
.local/bin/lf
Executable file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Ueberzugpp script for lf file explorer
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
UB_PID=0
|
||||||
|
UB_SOCKET=""
|
||||||
|
|
||||||
|
case "$(uname -a)" in
|
||||||
|
*Darwin*) UEBERZUG_TMP_DIR="$TMPDIR" ;;
|
||||||
|
*) UEBERZUG_TMP_DIR="/tmp" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
exec 3>&-
|
||||||
|
ueberzugpp cmd -s "$UB_SOCKET" -a exit
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||||
|
/usr/bin/lf "$@"
|
||||||
|
else
|
||||||
|
[ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
|
||||||
|
UB_PID_FILE="$UEBERZUG_TMP_DIR/.$(uuidgen)"
|
||||||
|
ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PID_FILE"
|
||||||
|
UB_PID=$(cat "$UB_PID_FILE")
|
||||||
|
rm "$UB_PID_FILE"
|
||||||
|
UB_SOCKET="$UEBERZUG_TMP_DIR/ueberzugpp-${UB_PID}.socket"
|
||||||
|
export UB_PID UB_SOCKET
|
||||||
|
trap cleanup HUP INT QUIT TERM EXIT
|
||||||
|
/usr/bin/lf "$@" 3>&-
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
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 --output x11 <"$FIFO_UEBERZUG" -p json &
|
|
||||||
exec 3>"$FIFO_UEBERZUG"
|
|
||||||
trap cleanup HUP INT QUIT TERM PWR EXIT
|
|
||||||
lf "$@" 3>&-
|
|
||||||
fi
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue