aboutsummaryrefslogtreecommitdiff
path: root/.config/lf/kitty_scope
diff options
context:
space:
mode:
authorawy <awy@tutamail.com>2024-08-13 11:46:15 +0300
committerawy <awy@tutamail.com>2024-08-13 11:46:15 +0300
commitac8b19f7c8bd1a4ec2a34a59268ce31285916d27 (patch)
tree634ea8fb638a093cba960806c3120793a975eba8 /.config/lf/kitty_scope
parentf8caaa9cd19b3e644b98303dfad382ecae18e8fc (diff)
fixes
Diffstat (limited to '.config/lf/kitty_scope')
-rwxr-xr-x.config/lf/kitty_scope29
1 files changed, 29 insertions, 0 deletions
diff --git a/.config/lf/kitty_scope b/.config/lf/kitty_scope
new file mode 100755
index 0000000..a7d0bc1
--- /dev/null
+++ b/.config/lf/kitty_scope
@@ -0,0 +1,29 @@
+#!/bin/sh
+draw() {
+ kitty +kitten icat --silent --stdin no --transfer-mode file --place "${w}x${h}@${x}x${y}" "$1" </dev/null >/dev/tty
+ exit 1
+}
+
+file="$1"
+w="$2"
+h="$3"
+x="$4"
+y="$5"
+
+case "$(file -Lb --mime-type "$file")" in
+ image/*)
+ draw "$file"
+ ;;
+ audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;;
+ video/*)
+ # vidthumb is from here:
+ # https://raw.githubusercontent.com/duganchen/kitty-pistol-previewer/main/vidthumb
+ CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
+ [ ! -f "$CACHE" ] && ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0
+ draw "$CACHE"
+ #draw "$(vidthumb "$file")"
+ ;;
+ text/* | */xml | application/json | application/x-ndjson) bat -p --theme ansi --terminal-width "$(($4-2))" -f "$1" ;;
+esac
+
+#pistol "$file"lace "${2}x${3}@${4}x${5}" "$1"