mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 13:26:37 +00:00
imgview: handle arguments as strings (#1509)
* imgview: handle arguments as strings Avoids the following synax errors: line 34: [: : integer expression expected line 49: [: : integer expression expected * imgview: use meaningful strings as arguments Co-authored-by: Florian Preinstorfer <florian@nblock.org> Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
This commit is contained in:
parent
f89ba77516
commit
b511506fa3
|
@ -31,8 +31,8 @@ exit_prompt() {
|
||||||
|
|
||||||
make_thumbs() {
|
make_thumbs() {
|
||||||
mkdir -p "$NNN_PREVIEWDIR$dir" || return
|
mkdir -p "$NNN_PREVIEWDIR$dir" || return
|
||||||
if [ "$1" -eq 3 ]; then
|
if [ "$1" = "viu" ] || [ "$1" = "catimg" ]; then
|
||||||
[ -d "$target" ] && exit_prompt "$2 can only display a single image"
|
[ -d "$target" ] && exit_prompt "$1 can only display a single image"
|
||||||
mime="$(file -bL --mime-type -- "$target")"
|
mime="$(file -bL --mime-type -- "$target")"
|
||||||
case "$mime" in
|
case "$mime" in
|
||||||
audio/*) ffmpeg -i "$target" "$NNN_PREVIEWDIR$target.jpg" -y >/dev/null 2>&1
|
audio/*) ffmpeg -i "$target" "$NNN_PREVIEWDIR$target.jpg" -y >/dev/null 2>&1
|
||||||
|
@ -45,8 +45,10 @@ make_thumbs() {
|
||||||
for file in "$dir"/*; do
|
for file in "$dir"/*; do
|
||||||
if [ ! -f "$NNN_PREVIEWDIR$file.jpg" ]; then
|
if [ ! -f "$NNN_PREVIEWDIR$file.jpg" ]; then
|
||||||
case "$(file -bL --mime-type -- "$file")" in
|
case "$(file -bL --mime-type -- "$file")" in
|
||||||
audio/*) [ "$1" -ne 0 ] && ffmpeg -i "$file" "$NNN_PREVIEWDIR$file.jpg" -y >/dev/null 2>&1 ;;
|
audio/*) [ "$1" != "sxiv" ] &&
|
||||||
video/*) [ "$1" -ne 1 ] && ffmpegthumbnailer -i "$file" -o "$NNN_PREVIEWDIR$file.jpg" 2> /dev/null ;;
|
ffmpeg -i "$file" "$NNN_PREVIEWDIR$file.jpg" -y >/dev/null 2>&1 ;;
|
||||||
|
video/*) [ "$1" != "ucollage" ] &&
|
||||||
|
ffmpegthumbnailer -i "$file" -o "$NNN_PREVIEWDIR$file.jpg" 2> /dev/null ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -77,33 +79,33 @@ 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 lsix
|
||||||
clear
|
clear
|
||||||
lsix
|
lsix
|
||||||
cd "$NNN_PREVIEWDIR$dir" && lsix
|
cd "$NNN_PREVIEWDIR$dir" && lsix
|
||||||
exit_prompt
|
exit_prompt
|
||||||
elif type ucollage >/dev/null 2>&1; then
|
elif type ucollage >/dev/null 2>&1; then
|
||||||
type ffmpeg >/dev/null 2>&1 && make_thumbs 1
|
type ffmpeg >/dev/null 2>&1 && make_thumbs ucollage
|
||||||
UCOLLAGE_EXPAND_DIRS=1 ucollage "$dir" "$NNN_PREVIEWDIR$dir" || exit_prompt
|
UCOLLAGE_EXPAND_DIRS=1 ucollage "$dir" "$NNN_PREVIEWDIR$dir" || exit_prompt
|
||||||
elif type sxiv >/dev/null 2>&1; then
|
elif type sxiv >/dev/null 2>&1; then
|
||||||
type ffmpegthumbnailer >/dev/null 2>&1 && make_thumbs 0
|
type ffmpegthumbnailer >/dev/null 2>&1 && make_thumbs sxiv
|
||||||
view_files sxiv >/dev/null 2>&1 &
|
view_files sxiv >/dev/null 2>&1 &
|
||||||
elif type nsxiv >/dev/null 2>&1; then
|
elif type nsxiv >/dev/null 2>&1; then
|
||||||
type ffmpegthumbnailer >/dev/null 2>&1 && make_thumbs 0
|
type ffmpegthumbnailer >/dev/null 2>&1 && make_thumbs sxiv
|
||||||
view_files nsxiv >/dev/null 2>&1 &
|
view_files nsxiv >/dev/null 2>&1 &
|
||||||
elif type imv >/dev/null 2>&1; then
|
elif type imv >/dev/null 2>&1; then
|
||||||
make_thumbs ""
|
make_thumbs imv
|
||||||
view_files imv >/dev/null 2>&1 &
|
view_files imv >/dev/null 2>&1 &
|
||||||
elif type imvr >/dev/null 2>&1; then
|
elif type imvr >/dev/null 2>&1; then
|
||||||
make_thumbs ""
|
make_thumbs imv
|
||||||
view_files imvr >/dev/null 2>&1 &
|
view_files imvr >/dev/null 2>&1 &
|
||||||
elif type viu >/dev/null 2>&1; then
|
elif type viu >/dev/null 2>&1; then
|
||||||
clear
|
clear
|
||||||
make_thumbs 3 viu
|
make_thumbs viu
|
||||||
viu -n "$ret"
|
viu -n "$ret"
|
||||||
exit_prompt
|
exit_prompt
|
||||||
elif type catimg >/dev/null 2>&1; then
|
elif type catimg >/dev/null 2>&1; then
|
||||||
make_thumbs 3 catimg
|
make_thumbs catimg
|
||||||
catimg "$ret"
|
catimg "$ret"
|
||||||
exit_prompt
|
exit_prompt
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue