mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-02-13 00:49:18 +01:00
Add kitty terminal support
This commit is contained in:
parent
70e79d417c
commit
58e608bb98
@ -3,5 +3,3 @@
|
|||||||
setup_fifo
|
setup_fifo
|
||||||
|
|
||||||
send_image "$f"
|
send_image "$f"
|
||||||
|
|
||||||
exit 1
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
setup_fifo 1
|
setup_fifo 1
|
||||||
|
|
||||||
printf '{"action": "remove", "identifier": "preview"}\n' > "$fifo"
|
if use_ueberzug; then
|
||||||
|
printf '{"action": "remove", "identifier": "preview"}\n' > "$fifo"
|
||||||
|
elif use_kitty; then
|
||||||
|
kitty +kitten icat --clear --transfer-mode file
|
||||||
|
fi
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
setup_fifo 1
|
setup_fifo 1
|
||||||
|
|
||||||
# tell ctpv server to exit
|
# tell ctpv server to exit
|
||||||
printf '\0' > "$fifo"
|
use_ueberzug && printf '\0' > "$fifo"
|
||||||
|
@ -2,6 +2,19 @@ echo_err() {
|
|||||||
echo "$@" >&2
|
echo "$@" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_kitty() {
|
||||||
|
[ -n "$KITTY_PID" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
use_ueberzug() {
|
||||||
|
exists ueberzug
|
||||||
|
}
|
||||||
|
|
||||||
|
use_kitty() {
|
||||||
|
use_ueberzug && return 1
|
||||||
|
is_kitty
|
||||||
|
}
|
||||||
|
|
||||||
fifo_open() {
|
fifo_open() {
|
||||||
# https://unix.stackexchange.com/a/522940/183147
|
# https://unix.stackexchange.com/a/522940/183147
|
||||||
dd oflag=nonblock conv=notrunc,nocreat count=0 of="$1" \
|
dd oflag=nonblock conv=notrunc,nocreat count=0 of="$1" \
|
||||||
@ -9,6 +22,8 @@ fifo_open() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup_fifo() {
|
setup_fifo() {
|
||||||
|
use_ueberzug || return 1
|
||||||
|
|
||||||
exit_code="${1:-127}"
|
exit_code="${1:-127}"
|
||||||
[ -n "$fifo" ] || exit "$exit_code"
|
[ -n "$fifo" ] || exit "$exit_code"
|
||||||
[ -e "$fifo" ] || exit "$exit_code"
|
[ -e "$fifo" ] || exit "$exit_code"
|
||||||
@ -24,9 +39,17 @@ check_exists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_image() {
|
send_image() {
|
||||||
path="$(printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g')"
|
if use_kitty; then
|
||||||
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"
|
kitty +kitten icat --transfer-mode file --align left \
|
||||||
return 1
|
--place "${w}x${h}@${x}x${y}" "$1"
|
||||||
|
return 1
|
||||||
|
elif use_ueberzug; then
|
||||||
|
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"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 127
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_and_show_image() {
|
convert_and_show_image() {
|
||||||
|
Loading…
Reference in New Issue
Block a user