Fallback to ascii mode if w3m and/or imagemagick aren't installed

This commit is contained in:
Dylan 2016-01-29 00:00:08 +11:00
parent 651cc28f71
commit c54775574f

22
fetch
View file

@ -1353,14 +1353,14 @@ getascii () {
fi fi
# We only use eval in the distro ascii files. # We only use eval in the distro ascii files.
print="$(eval printf "$(<$ascii)")" print="$(eval printf "$(<"$ascii")")"
else else
case "$ascii_color" in case "$ascii_color" in
"distro") ascii_color="$c1" ;; "distro") ascii_color="$c1" ;;
*) ascii_color="$(color $ascii_color)" ;; *) ascii_color="$(color $ascii_color)" ;;
esac esac
print="${ascii_color}$(<$ascii)" print="${ascii_color}$(<"$ascii")"
fi fi
# Strip escape codes backslashes from contents of # Strip escape codes backslashes from contents of
@ -1389,6 +1389,16 @@ getascii () {
# Image {{{ # Image {{{
getimage () { getimage () {
# Fallback to ascii mode if imagemagick isn't installed.
if ! type -p convert >/dev/null 2>&1; then
image="ascii"
fi
# Fallback to ascii mode if image mode is 'w3m' and 'w3m' isn't installed.
if [ "$image_backend" == "w3m" ] && ! type -p $w3m_img_path >/dev/null 2>&1; then
image="ascii"
fi
# Make the directory if it doesn't exist # Make the directory if it doesn't exist
mkdir -p "$imgtempdir" mkdir -p "$imgtempdir"
@ -1450,14 +1460,6 @@ getimage () {
# Check to see if the thumbnail exists before we do any cropping. # Check to see if the thumbnail exists before we do any cropping.
if [ ! -f "$imgtempdir/$imgname" ]; then if [ ! -f "$imgtempdir/$imgname" ]; then
# Check to see that imagemagick is installed
# if not then disable images
if ! type -p convert >/dev/null 2>&1; then
image="off"
padding="\033[0C"
return
fi
# Get image size so that we can do a better crop # Get image size so that we can do a better crop
size=$(identify -format "%w %h" "$img") size=$(identify -format "%w %h" "$img")
width=${size%% *} width=${size%% *}