mirror of
https://git.disroot.org/FollieHiyuki/dotfiles.git
synced 2024-11-27 09:48:36 -05:00
40 lines
1.1 KiB
Bash
Executable File
40 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
X="$2"
|
|
Y="$3"
|
|
WIDTH="$4"
|
|
HEIGHT="$5"
|
|
TMP="/tmp/vifm_thumb.png"
|
|
|
|
_preview_video() {
|
|
ffmpegthumbnailer -i "$1" -o "$TMP" -s 0
|
|
kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$TMP"
|
|
}
|
|
|
|
_preview_image() {
|
|
convert -- "$1" "$TMP"
|
|
kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$TMP"
|
|
}
|
|
|
|
case "$1" in
|
|
# First check common extensions
|
|
*.png|*.jpg|*.bmp|*.jpeg|*.gif|*.xpm) kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$1" ;;
|
|
*.avi|*.mp4|*.wmv|*.dat|*.3gp|*.vob|*.ogv|*.mkv|*.mpe?g|*.fl[icv]|*.m2v|*.webm|*.m?ts|*.r[am]|*.qt|*.divx|*.as[fx]|*.m4v|*.mov) _preview_video "$1" ;;
|
|
# Then fallback to mimetypes
|
|
*)
|
|
mimetype=$(file --dereference --brief --mime-type -- "$1")
|
|
case "$mimetype" in
|
|
image/vnd.djvu)
|
|
djvutxt "$1" || exiftool "$1" ;;
|
|
image/*)
|
|
_preview_image "$1" ;;
|
|
application/font*|application/*opentype|font/*)
|
|
genfontimage "$1" "$TMP"
|
|
kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$TMP" ;;
|
|
video/*)
|
|
_preview_video "$1" ;;
|
|
*)
|
|
exit 1 ;;
|
|
esac ;;
|
|
esac
|