Another vifm update
3 files changed, 81 insertions(+), 3 deletions(-)

M .config/vifm/vifmrc
A => bin/vifmimg
A => bin/vifmrun
M .config/vifm/vifmrc +3 -3
@@ 247,9 247,9 @@ fileviewer *.[1-8] man ./%c | col -b
 "fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
 "         \ convert -identify %f -verbose /dev/null
 
-fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
-         \ show-sixel %c %pw %ph %pd
-" fileviewer *.jpg,*.jpeg,*.png,*.ico vifmimg draw %px %py %pw %ph %c %pc vifmimg clear
+" fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
+"          \ show-sixel %c %pw %ph %pd
+fileviewer *.jpg,*.jpeg,*.png,*.ico vifmimg draw %px %py %pw %ph %c %pc vifmimg clear
 " filextype *.bmp,*.jpg,*.jpeg,*.png,*.ico,*.gif,*.xpm  rotdir %f 2>/dev/null | sxiv -ia 2>/dev/null &
 filextype *.bmp,*.jpg,*.jpeg,*.png,*.ico,*.gif,*.xpm  sxiv -ia 2>/dev/null &
 

          
A => bin/vifmimg +57 -0
@@ 0,0 1,57 @@ 
+#!/bin/sh
+
+#PCACHE="$HOME/.cache/vifm/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$PWD/$6")" | sha256sum)"
+PCACHE="$HOME/.cache/vifm/thumbnail.$(stat -c '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$PWD/$6")" | sha256sum)"
+export PCACHE="${PCACHE%% *}"
+
+pclear() {
+	printf '{"action": "remove", "identifier": "vifm-preview"}\n' > "$FIFO_UEBERZUG"
+}
+
+image() {
+		printf '{"action": "add", "identifier": "vifm-preview", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$2" "$3" "$4" "$5" "$6" > "$FIFO_UEBERZUG"
+}
+
+main() {
+    case "$1" in
+        "clear")
+			pclear "$@"
+			;;
+        "draw")
+			FILE="$PWD/$6"
+			image "$1" "$2" "$3" "$4" "$5" "$FILE"
+			;;
+        "video")
+			[ ! -f "${PCACHE}.jpg" ] && \
+				ffmpegthumbnailer -i "$6" -o "${PCACHE}.jpg" -s 0 -q 5
+			image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
+			;;
+        "epub")
+			[ ! -f "$PCACHE" ] && \
+				epub-thumbnailer "$6" "$PCACHE" 1024
+			image "$1" "$2" "$3" "$4" "$5" "$PCACHE"
+			;;
+        "pdf")
+			[ ! -f "${PCACHE}.jpg" ] && \
+				pdftoppm -jpeg -f 1 -singlefile "$6" "$PCACHE"
+			image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
+			;;
+        "djvu")
+			[ ! -f "${PCACHE}.jpg" ] && \
+				ddjvu -format=tiff -quality=90 -page=1 "$6" "$PCACHE.jpg"
+			image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
+			;;
+        "audio")
+			[ ! -f "${PCACHE}.jpg" ] && \
+				ffmpeg -hide_banner -i "$6" "${PCACHE}.jpg" -y >/dev/null
+			image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
+			;;
+        "font")
+			[ ! -f "${PCACHE}.jpg" ] && \
+				fontpreview -i "$6" -o "${PCACHE}.jpg"
+			image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.jpg"
+			;;
+        *)
+    esac
+}
+main "$@"

          
A => bin/vifmrun +21 -0
@@ 0,0 1,21 @@ 
+#!/bin/sh
+
+if [ -z "$(command -v vifm)" ]; then
+	printf "vifm isn't installed on your system!\n"
+	exit 1
+elif [ -z "$(command -v ueberzug)" ]; then
+	exec vifm "$@"
+else
+	cleanup() {
+		exec 3>&-
+	    rm "$FIFO_UEBERZUG"
+	}
+	[ ! -d "$HOME/.cache/vifm" ] && mkdir -p "$HOME/.cache/vifm"
+	export FIFO_UEBERZUG="$HOME/.cache/vifm/ueberzug-${$}"
+	mkfifo "$FIFO_UEBERZUG"
+	ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
+	exec 3>"$FIFO_UEBERZUG"
+	trap cleanup EXIT
+	vifm "$@" 3>&-
+	vifmimg clear
+fi