mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-24 12:00:24 +10:00
Updating vifmimg and vifmrc to include pdf image previews.
This commit is contained in:
@@ -1,20 +1,53 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
readonly ID_PREVIEW="preview"
|
readonly ID_PREVIEW="preview"
|
||||||
|
|
||||||
|
#AUTO_REMOVE="yes"
|
||||||
|
# By enabling this option the script will remove the preview file after it is drawn
|
||||||
|
# and by doing so the preview will always be up-to-date with the file.
|
||||||
|
# This however, requires more CPU and therefore affects the overall performance.
|
||||||
|
|
||||||
if [ -e "$FIFO_UEBERZUG" ]; then
|
if [ -e "$FIFO_UEBERZUG" ]; then
|
||||||
if [[ "$1" == "draw" ]]; then
|
if [[ "$1" == "draw" ]]; then
|
||||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||||
[path]="${PWD}/$6") \
|
[path]="${PWD}/$6") \
|
||||||
> "$FIFO_UEBERZUG"
|
> "$FIFO_UEBERZUG"
|
||||||
|
|
||||||
elif [[ "$1" == "videopreview" ]]; then
|
elif [[ "$1" == "videopreview" ]]; then
|
||||||
[[ ! -f "/tmp/$6.png" ]] && ffmpegthumbnailer -i "${PWD}/$6" -o "/tmp/$6.png" -s 0 -q 10
|
echo -e "Loading preview..\nFile: $6"
|
||||||
|
[[ ! -d "/tmp${PWD}/$6/" ]] && mkdir -p "/tmp${PWD}/$6/"
|
||||||
|
[[ ! -f "/tmp${PWD}/$6.png" ]] && ffmpegthumbnailer -i "${PWD}/$6" -o "/tmp${PWD}/$6.png" -s 0 -q 10
|
||||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||||
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||||
[path]="/tmp/$6.png") \
|
[path]="/tmp${PWD}/$6.png") \
|
||||||
> "$FIFO_UEBERZUG"
|
> "$FIFO_UEBERZUG"
|
||||||
|
|
||||||
|
elif [[ "$1" == "gifpreview" ]]; then
|
||||||
|
echo -e "Loading preview..\nFile: $6"
|
||||||
|
[[ ! -d "/tmp${PWD}/$6/" ]] && mkdir -p "/tmp${PWD}/$6/" && convert -coalesce "${PWD}/$6" "/tmp${PWD}/$6/$6.png"
|
||||||
|
for frame in $(ls -1 /tmp${PWD}/$6/$6*.png | sort -V); do
|
||||||
|
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||||
|
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||||
|
[path]="$frame") \
|
||||||
|
> "$FIFO_UEBERZUG"
|
||||||
|
# Sleep between frames to make the animation smooth.
|
||||||
|
sleep .07
|
||||||
|
done
|
||||||
|
|
||||||
|
elif [[ "$1" == "pdfpreview" ]]; then
|
||||||
|
echo -e "Loading preview..\nFile: $6"
|
||||||
|
[[ ! -d "/tmp${PWD}/$6/" ]] && mkdir -p "/tmp${PWD}/$6/"
|
||||||
|
[[ ! -f "/tmp${PWD}/$6.png" ]] && pdftoppm -png -singlefile "$6" "/tmp${PWD}/$6"
|
||||||
|
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
|
||||||
|
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \
|
||||||
|
[path]="/tmp${PWD}/$6.png") \
|
||||||
|
> "$FIFO_UEBERZUG"
|
||||||
|
|
||||||
elif [[ "$1" == "clear" ]]; then
|
elif [[ "$1" == "clear" ]]; then
|
||||||
declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") \
|
declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") \
|
||||||
> "$FIFO_UEBERZUG"
|
> "$FIFO_UEBERZUG"
|
||||||
|
[[ ! -z $AUTO_REMOVE ]] && [[ -f "/tmp${PWD}/$6.png" ]] && rm -f "/tmp${PWD}/$6.png"
|
||||||
|
[[ ! -z $AUTO_REMOVE ]] && [[ -d "/tmp${PWD}/$6/" ]] && rm -rf "/tmp${PWD}/$6/"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -179,7 +179,11 @@ command! reload :write | restart
|
|||||||
|
|
||||||
" Pdf
|
" Pdf
|
||||||
filextype *.pdf zathura %c %i &, apvlv %c, xpdf %c
|
filextype *.pdf zathura %c %i &, apvlv %c, xpdf %c
|
||||||
fileviewer *.pdf pdftotext -nopgbrk %c -
|
fileviewer *.pdf
|
||||||
|
\ vifmimg pdfpreview %px %py %pw %ph %c
|
||||||
|
\ %pc
|
||||||
|
\ vifmimg clear
|
||||||
|
" \ pdftotext -nopgbrk %c -
|
||||||
|
|
||||||
" PostScript
|
" PostScript
|
||||||
filextype *.ps,*.eps,*.ps.gz
|
filextype *.ps,*.eps,*.ps.gz
|
||||||
@@ -249,7 +253,7 @@ filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
|
|||||||
\ feh %d &,
|
\ feh %d &,
|
||||||
\ {View in cacaview}
|
\ {View in cacaview}
|
||||||
\ cacaview %c &,
|
\ cacaview %c &,
|
||||||
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
|
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.xpm
|
||||||
\ vifmimg draw %px %py %pw %ph %c
|
\ vifmimg draw %px %py %pw %ph %c
|
||||||
\ %pc
|
\ %pc
|
||||||
\ vifmimg clear
|
\ vifmimg clear
|
||||||
@@ -257,6 +261,10 @@ fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
|
|||||||
" \ imgt %px %py %pw %ph %c
|
" \ imgt %px %py %pw %ph %c
|
||||||
" \ %pc
|
" \ %pc
|
||||||
" \ imgc %px %py %pw %ph NOT NEEDED IN XTERM
|
" \ imgc %px %py %pw %ph NOT NEEDED IN XTERM
|
||||||
|
fileviewer *.gif
|
||||||
|
\ vifmimg gifpreview %px %py %pw %ph %c
|
||||||
|
\ %pc
|
||||||
|
\ vifmimg clear
|
||||||
|
|
||||||
" OpenRaster
|
" OpenRaster
|
||||||
filextype *.ora
|
filextype *.ora
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
-- | |_| || | http://www.gitlab.com/dwt1/
|
-- | |_| || | http://www.gitlab.com/dwt1/
|
||||||
-- |____/ |_|
|
-- |____/ |_|
|
||||||
--
|
--
|
||||||
-- A customized configuration for xmonad window manager (http://www.xmonad.org)
|
-- My configuration for the xmonad window manager (http://www.xmonad.org)
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
---IMPORTS
|
---IMPORTS
|
||||||
|
|||||||
Reference in New Issue
Block a user