mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Merge pull request #1049 from luukvbaal/imgview
Plugin imgview improvements
This commit is contained in:
commit
14be56057c
|
@ -11,8 +11,8 @@
|
||||||
# - lsix (https://github.com/hackerb9/lsix), or
|
# - lsix (https://github.com/hackerb9/lsix), or
|
||||||
# - viu (https://github.com/atanunq/viu), or
|
# - viu (https://github.com/atanunq/viu), or
|
||||||
# - catimg (https://github.com/posva/catimg), or
|
# - catimg (https://github.com/posva/catimg), or
|
||||||
# - optional: ffmpegthumbnailer for video thumbnails
|
|
||||||
# - optional: ffmpeg for audio thumbnails (album art)
|
# - optional: ffmpeg for audio thumbnails (album art)
|
||||||
|
# - optional: ffmpegthumbnailer for video thumbnails
|
||||||
#
|
#
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Arun Prakash Jana, Luuk van Baal
|
# Author: Arun Prakash Jana, Luuk van Baal
|
||||||
|
@ -37,24 +37,35 @@ nthumb_cleanup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
make_thumbs() {
|
make_thumbs() {
|
||||||
if [ -d "$target" ]; then cd "$target" || exit_prompt; fi
|
if [ -d "$target" ]; then
|
||||||
|
[ "$1" -eq 4 ] && exit_prompt "$3 can only display a single image"
|
||||||
|
cd "$target" || exit_prompt
|
||||||
|
fi
|
||||||
if mkdir .nthumbs >/dev/null; then
|
if mkdir .nthumbs >/dev/null; then
|
||||||
thumbs=1
|
thumbs=1
|
||||||
else
|
else
|
||||||
exit_prompt
|
exit_prompt
|
||||||
fi
|
fi
|
||||||
|
if [ "$1" -eq 4 ]; then
|
||||||
|
mime="$(file -bL --mime-type -- "$2")"
|
||||||
|
case "$mime" in
|
||||||
|
audio/*) ffmpeg -i "$2" ".nthumbs/${2%%.*}.jpg" -y >/dev/null 2>&1
|
||||||
|
ret=".nthumbs/${2%%.*}.jpg" ;;
|
||||||
|
video/*) ffmpegthumbnailer -i "$2" -o .nthumbs/"${2%%.*}".jpg 2> /dev/null
|
||||||
|
ret=".nthumbs/${2%%.*}.jpg" ;;
|
||||||
|
*) ret="$2" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
for file in *; do
|
for file in *; do
|
||||||
case "$(file -bL --mime-type -- "$file")" in
|
case "$(file -bL --mime-type -- "$file")" in
|
||||||
image/*) ln -s "$PWD/$file" "$PWD/.nthumbs/$file" ;;
|
audio/*) [ "$1" -ne 0 ] && ffmpeg -i "$file" ".nthumbs/${file%%.*}.jpg" -y >/dev/null 2>&1 ;;
|
||||||
audio/*) ffmpeg -i "$file" ".nthumbs/${file%%.*}.jpg" -y >/dev/null 2>&1;;
|
video/*) [ "$1" -ne 1 ] && ffmpegthumbnailer -i "$file" -o .nthumbs/"${file%%.*}".jpg 2> /dev/null ;;
|
||||||
video/*) ffmpegthumbnailer -i "$file" -o .nthumbs/"${file%%.*}".jpg 2> /dev/null ;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
cd .nthumbs || return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view_dir() {
|
view_files() {
|
||||||
find . -maxdepth 0 -print0 | xargs -0 "$1" --
|
find . .nthumbs -maxdepth 1 -type f -print0 | xargs -0 "$@" --
|
||||||
}
|
}
|
||||||
|
|
||||||
if uname | grep -q "Darwin"; then
|
if uname | grep -q "Darwin"; then
|
||||||
|
@ -63,46 +74,44 @@ elif type lsix >/dev/null 2>&1; then
|
||||||
if [ -d "$target" ]; then
|
if [ -d "$target" ]; then
|
||||||
cd "$target" || exit_prompt
|
cd "$target" || exit_prompt
|
||||||
fi
|
fi
|
||||||
make_thumbs
|
make_thumbs ""
|
||||||
clear
|
clear
|
||||||
lsix
|
lsix
|
||||||
|
cd .nthumbs && lsix
|
||||||
nthumb_cleanup
|
nthumb_cleanup
|
||||||
exit_prompt
|
exit_prompt
|
||||||
elif type ucollage >/dev/null 2>&1; then
|
elif type ucollage >/dev/null 2>&1; then
|
||||||
make_thumbs
|
make_thumbs 1
|
||||||
ucollage
|
if ! UCOLLAGE_EXPAND_DIRS=1 ucollage . .nthumbs; then
|
||||||
|
nthumb_cleanup && exit_prompt
|
||||||
|
fi
|
||||||
nthumb_cleanup
|
nthumb_cleanup
|
||||||
exit
|
exit
|
||||||
elif type sxiv >/dev/null 2>&1; then
|
elif type sxiv >/dev/null 2>&1; then
|
||||||
make_thumbs
|
make_thumbs 0
|
||||||
if [ -f "$target" ]; then
|
if [ -f "$target" ]; then
|
||||||
view_dir sxiv >/dev/null 2>&1 &
|
view_files sxiv >/dev/null 2>&1 &
|
||||||
elif [ -d "$target" ]; then
|
elif [ -d "$target" ]; then
|
||||||
sxiv -aqt . >/dev/null 2>&1 &
|
view_files sxiv -aqt >/dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
elif type imv >/dev/null 2>&1; then
|
elif type imv >/dev/null 2>&1; then
|
||||||
make_thumbs
|
make_thumbs 3
|
||||||
if [ -f "$target" ]; then
|
view_files imv >/dev/null 2>&1 &
|
||||||
view_dir imv >/dev/null 2>&1 &
|
|
||||||
elif [ -d "$target" ]; then
|
|
||||||
imv . >/dev/null 2>&1 &
|
|
||||||
fi
|
|
||||||
elif type imvr >/dev/null 2>&1; then
|
elif type imvr >/dev/null 2>&1; then
|
||||||
make_thumbs
|
make_thumbs 3
|
||||||
if [ -f "$target" ]; then
|
view_files imvr >/dev/null 2>&1 &
|
||||||
view_dir imvr >/dev/null 2>&1 &
|
|
||||||
elif [ -d "$target" ]; then
|
|
||||||
imvr . >/dev/null 2>&1 &
|
|
||||||
fi
|
|
||||||
elif type viu >/dev/null 2>&1; then
|
elif type viu >/dev/null 2>&1; then
|
||||||
clear
|
clear
|
||||||
viu -n "$1"
|
make_thumbs 4 "$1" viu
|
||||||
|
viu -n "$ret"
|
||||||
|
nthumb_cleanup
|
||||||
exit_prompt
|
exit_prompt
|
||||||
elif type catimg >/dev/null 2>&1; then
|
elif type catimg >/dev/null 2>&1; then
|
||||||
clear
|
make_thumbs 4 "$1" catimg
|
||||||
catimg "$1"
|
catimg "$ret"
|
||||||
|
nthumb_cleanup
|
||||||
exit_prompt
|
exit_prompt
|
||||||
else
|
else
|
||||||
exit_prompt "Please install sxiv/imv/viu/catimg/lsix."
|
exit_prompt "Please install sxiv/imv/viu/catimg/lsix."
|
||||||
fi
|
fi
|
||||||
[ -n "$thumbs" ] && nthumb_cleanup &
|
[ "$thumbs" -ne 0 ] && nthumb_cleanup &
|
||||||
|
|
Loading…
Reference in a new issue