Improve preview script (again)
Convert the image file to JPG and cache it if chafa cannot print the original file to the terminal. Also remove fallback previewer, as it will mangle vifm's preview pane with passthrough flag %N enabled.
This commit is contained in:
parent
32867f005c
commit
bd35665c21
|
@ -7,6 +7,9 @@ _cache_thumbnail() {
|
|||
tmpfile="${thumbnail_dir}/$(stat -c '%n%i%F%s%Y' -- "$(readlink -f "$2")" | sha256sum | awk '{print $1}').jpg"
|
||||
if [ ! -f "$tmpfile" ]; then
|
||||
case "$1" in
|
||||
image)
|
||||
convert -- "$2"'[0]' "$tmpfile"
|
||||
;;
|
||||
video)
|
||||
ffmpegthumbnailer -i "$2" -o "$tmpfile" -s 0
|
||||
;;
|
||||
|
@ -41,15 +44,15 @@ _preview_markdown() {
|
|||
}
|
||||
|
||||
_preview_image() {
|
||||
chafa --animate=off --polite=on --size="$2"x"$3" "$1" || exiftool "$1"
|
||||
chafa --animate=off --polite=on --size="$2"x"$3" "$1" || chafa --animate=off --polite=on --size="$2"x"$3" "$(_cache_thumbnail image "$1")"
|
||||
}
|
||||
|
||||
_preview_video() {
|
||||
_preview_image "$(_cache_thumbnail video "$1")" "$2" "$3" || fprobe -hide_banner -pretty "$1" || exiftool "$1"
|
||||
_preview_image "$(_cache_thumbnail video "$1")" "$2" "$3"
|
||||
}
|
||||
|
||||
_preview_font() {
|
||||
_preview_image "$(_cache_thumbnail font "$1")" "$2" "$3" || exiftool "$1"
|
||||
_preview_image "$(_cache_thumbnail font "$1")" "$2" "$3"
|
||||
}
|
||||
|
||||
# Take 2 additional arguments as width and height (rows/cols)
|
||||
|
|
Loading…
Reference in New Issue