diff options
author | ZachIR <zachir@librem.one> | 2025-02-28 11:40:36 -0600 |
---|---|---|
committer | ZachIR <zachir@librem.one> | 2025-02-28 11:43:53 -0600 |
commit | 5f057879086ec863dbcbadcb2cfdcc61a68a62ce (patch) | |
tree | 9878ada401e51c68cb7451b668fdc92ff23b35cd /lf/previewer | |
parent | a4e6a837c6edc8f1c2ea8f714ce84f61a3629715 (diff) |
Add cleaner and preview to fix lf
Diffstat (limited to 'lf/previewer')
-rwxr-xr-x | lf/previewer | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lf/previewer b/lf/previewer new file mode 100755 index 0000000..24db043 --- /dev/null +++ b/lf/previewer @@ -0,0 +1,36 @@ +#!/bin/sh +draw() { + kitten icat --stdin no --transfer-mode memory --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" + ;; + video/*) + # vidthumb is from here: + # https://raw.githubusercontent.com/duganchen/kitty-pistol-previewer/main/vidthumb + draw "$(vidthumb "$file")" + ;; + application/pdf) + CACHE=$(mktemp /tmp/thumbcache.XXXXX) + pdftoppm -png -f 1 -singlefile "$1" "$CACHE" + draw "$CACHE.png" + rm -f "$CACHE" "$CACHE.png" + ;; + application/epub+zip|application/epub) + CACHE=$(mktemp /tmp/thumbcache.XXXXX) + epub-thumbnailer "$1" "$CACHE" 1024 + $HOME/.config/lf/image draw "$CACHE" + rm -f "$CACHE" "$CACHE.png" + ;; +esac + +pistol "$file" |