Add support for avif in lf (#1262)

Co-authored-by: Victor Risgaard <victor@risgaard.xyz>
This commit is contained in:
PrivateLalle 2023-02-07 14:51:00 +01:00 committed by GitHub
parent 6d75bbdf8c
commit 88748a4800
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -34,7 +34,7 @@ cmd open ${{
text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;; text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;; image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
image/svg+xml) display -- $f ;; image/svg+xml) display -- $f ;;
image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|tif\|ico\)\(_large\)*$" | image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" |
setsid -f sxiv -aio 2>/dev/null | while read -r file; do setsid -f sxiv -aio 2>/dev/null | while read -r file; do
[ -z "$file" ] && continue [ -z "$file" ] && continue
lf -remote "send select \"$file\"" lf -remote "send select \"$file\""

View file

@ -22,6 +22,9 @@ ifub() {
# be regenerated once seen. # be regenerated once seen.
case "$(file --dereference --brief --mime-type -- "$1")" in case "$(file --dereference --brief --mime-type -- "$1")" in
image/avif) 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" ] && convert "$1" "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;;
image/*) image "$1" "$2" "$3" "$4" "$5" "$1" ;; image/*) image "$1" "$2" "$3" "$4" "$5" "$1" ;;
text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;; text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;;
text/troff) man ./ "$1" | col -b ;; text/troff) man ./ "$1" | col -b ;;