This commit is contained in:
Nikita Ivanov 2022-05-29 01:38:29 +05:00
parent d67d10af9f
commit 647f07bab5
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133
2 changed files with 3 additions and 4 deletions

View File

@ -23,7 +23,7 @@ cache() {
cache_f="$("$ctpv" -C "$f")" cache_f="$("$ctpv" -C "$f")"
} }
show_image() { send_image() {
path="$(printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g')" path="$(printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g')"
printf '{ "action": "add", "identifier": "preview", "x": %d, "y": %d, "width": %d, "height": %d, "scaler": "contain", "scaling_position_x": 0.5, "scaling_position_y": 0.5, "path": "%s"}\n' "$x" "$y" "$w" "$h" "$path" > "$fifo" printf '{ "action": "add", "identifier": "preview", "x": %d, "y": %d, "width": %d, "height": %d, "scaler": "contain", "scaling_position_x": 0.5, "scaling_position_y": 0.5, "path": "%s"}\n' "$x" "$y" "$w" "$h" "$path" > "$fifo"
} }
@ -31,6 +31,6 @@ show_image() {
convert_and_show_image() { convert_and_show_image() {
setup_fifo setup_fifo
cache || "$@" || check_exist cache || "$@" || check_exist
show_image "$cache_f" send_image "$cache_f"
exit 1 exit 1
} }

View File

@ -1,6 +1,5 @@
# exit 127 on error so ctpv fallbacks to another preview
setup_fifo setup_fifo
show_image "$f" send_image "$f"
exit 1 exit 1