diff options
| author | pants <niklasjo2004@gmail.com> | 2026-09-21 14:18:06 -0700 |
|---|---|---|
| committer | pants <niklasjo2004@gmail.com> | 2026-09-21 14:18:06 -0700 |
| commit | 83d5ba42f8a98fc0df177efef4333f74a0481f61 (patch) | |
| tree | 6f1fcff64ec9adb2fc51a7cfcc451eb22a103fb3 /scripts/fifo/img-fifo | |
Diffstat (limited to 'scripts/fifo/img-fifo')
| -rwxr-xr-x | scripts/fifo/img-fifo | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/fifo/img-fifo b/scripts/fifo/img-fifo new file mode 100755 index 0000000..78aeb9d --- /dev/null +++ b/scripts/fifo/img-fifo @@ -0,0 +1,31 @@ +#!/bin/sh + +# This is a simple script that allows you to use ueberzugpp to +# preview images in the terminal by providing the x and y +# coordinates of the image, the width and height of the image, +# and the path to the image file, with $1, $2, $3, $4 and $5 +# as arguments, respectively. +# Example usage: +# ./img-fifo 0 0 30 30 image.jpg +# Use Ctrl+C to exit. + +FIFO="/tmp/preview_fifo" +[ -p "$FIFO" ] || mkfifo "$FIFO" + +start_ueberzugpp() { + ueberzugpp layer --silent <"$FIFO" & + exec 3>"${FIFO}" +} + +cleanup() { + rm -f "$FIFO" +} +trap cleanup HUP INT QUIT TERM EXIT + +preview_image() { + echo '{"path": "'"$5"'", "action": "add", "identifier": "img-fifo", "x": "'"$1"'", "y": "'"$2"'", "width": "'"$3"'", "height": "'"$4"'"}' >"$FIFO" +} + +start_ueberzugpp +preview_image "$1" "$2" "$3" "$4" "$5" +wait |
