summaryrefslogtreecommitdiff
path: root/mac/.config/lf/scope
diff options
context:
space:
mode:
Diffstat (limited to 'mac/.config/lf/scope')
-rwxr-xr-xmac/.config/lf/scope14
1 files changed, 10 insertions, 4 deletions
diff --git a/mac/.config/lf/scope b/mac/.config/lf/scope
index fc26f5e..2a2f7fa 100755
--- a/mac/.config/lf/scope
+++ b/mac/.config/lf/scope
@@ -7,10 +7,16 @@ IFS="$(printf '%b_' '\n')"
IFS="${IFS%_}"
image() {
- if [ -f "$1" ] && [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzugpp >/dev/null 2>&1; then
- printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$4" "$(($5 + 1))" "$(($2 - 1))" "$(($3 - 2))" "$1" >"$FIFO_UEBERZUGPP"
+ if [ -f "$1" ] && command -v kitty >/dev/null 2>&1; then
+ file=$1
+ w=$2
+ h=$3
+ x=$4
+ y=$5
+ kitty +kitten icat --silent --stdin no --transfer-mode file --place "${w}x${h}@${x}x${y}" "$file" </dev/null >/dev/tty
mediainfo --Output="Video;%Duration/String%" "$6"
else
+ chafa "$1" -s "$4x"
mediainfo "$6"
fi
}
@@ -30,12 +36,12 @@ image/vnd.djvu)
[ ! -f "$CACHE" ] && djvused "$1" -e 'select 1; save-page-with /dev/stdout' | magick -density 200 - "$CACHE.jpg" >/dev/null 2>&1
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;;
-image/svg+xml)
+image/svg+xml | image/png)
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" ] && inkscape --convert-dpi-method=none -o "$CACHE.png" --export-overwrite -D --export-png-color-mode=RGBA_16 "$1"
image "$CACHE.png" "$2" "$3" "$4" "$5" "$1"
;;
-image/x-xcf)
+image/x-xcf | image/jpg | image/jpeg)
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 | awk '{print $1}')"
[ ! -f "$CACHE.jpg" ] && magick "$1[0]" "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"