Add ability to use pixterm for img previews

This commit is contained in:
ItsDrike 2021-08-17 03:51:45 +02:00
parent 41522e8b0d
commit 00780218bd
No known key found for this signature in database
GPG key ID: B5F6B41F708C3ADD
2 changed files with 28 additions and 11 deletions

View file

@ -1,11 +1,21 @@
#!/bin/sh
readonly PREVIEW_ID="preview"
printf '{"action": "add", "identifier": "%s", "x": %d, "y": %d, "width": %d, "height": %d, "scaler": "contain", "scaling_position_x": 0.5, "scaling_position_y": 0.5, "path": "%s"}\n' \
"$PREVIEW_ID" "$2" "$3" "$4" "$5" "$1" > "$FIFO_UEBERZUG"
#declare -p -A cmd=([action]=add [identifier]="$PREVIEW_ID" \
# [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" \
# [path]="$1") > "$FIFO_UEBERZUG"
path="$1"
x="$2"
y="$3"
width="$4"
height="$5"
PREVIEW_ID="preview"
if [ -n "$FIFO_UEBERZUG" ]; then
printf '{"action": "add", "identifier": "%s", "x": %d, "y": %d, "width": %d, "height": %d, "scaler": "contain", "scaling_position_x": 0.5, "scaling_position_y": 0.5, "path": "%s"}\n' \
"$PREVIEW_ID" "$x" "$y" "$width" "$height" "$path" > "$FIFO_UEBERZUG"
else
# Ueberzug isn't avialable, try to use pixterm
if command -v pixterm > /dev/null; then
pixterm -s 2 -tr "$x" -tc "$width" "$path"
else
>&2 echo "ueberzug not running, pixterm fallback not found!"
exit 1
fi
fi