diff --git a/neofetch b/neofetch index 67df7035..d99908b4 100755 --- a/neofetch +++ b/neofetch @@ -1832,9 +1832,9 @@ get_image_backend() { # If image source is ascii fallback to ascii. if [[ "$image_source" == "ascii" ]]; then - image_backend="ascii" - err "Image: \$image_source set to 'ascii', falling back to ascii mode. " + to_ascii "Image: \$image_source set to 'ascii', falling back to ascii mode." err "Image: Change \$image_source to another value to use image mode." + return fi case "${image_backend:=image}" in @@ -1861,8 +1861,9 @@ get_image_backend() { get_term_size # Fallback to ascii mode if terminal size wasn't found. - if [[ -z "$term_width" ]] && ((term_width == 0)); then + if [[ -z "$term_width" ]] || ((term_width == 0)); then to_ascii "Image: Failed to find terminal window size" + err "Image: Check the 'Images in the terminal' wiki page for more info" return fi @@ -1878,8 +1879,7 @@ get_image_backend() { esac # Set cursor position next to ascii art. - [[ "$image_backend" != "off" ]] && \ - printf "%b" "\033[$((${lines:-0} - ${prompt_loc:-0}))A\033[9999999D" + [[ "$image_backend" != "off" ]] && printf "%b" "\033[${lines:-0}A\033[9999999D" } get_ascii() { @@ -2063,7 +2063,7 @@ get_term_size() { # The escape codes above print the desired output as # user input so we have to use read to store the out # -put as a variable. - builtin read -s -t 1 "${read_flags[@]}" -r term_size + IFS=";" read -s -t 1 "${read_flags[@]}" -r -a term_size # Split the string into height/width. if [[ "$image_program" == "tycat" ]]; then @@ -2072,16 +2072,12 @@ get_term_size() { term_height="$((term_size[3] * term_size[1]))" else - term_size="${term_size//'['}" - term_size="${term_size/';'}" - term_size="${term_size/$'\E4'}" - term_size="${term_size/t*}" - term_height="${term_size/';'*}" - term_width="${term_size/*';'}" + term_height="${term_size[1]}" + term_width="${term_size[2]/t*}" fi # Get terminal width/height if \033[14t is unsupported. - if (("${#term_size}" <= 5)) && [[ "$image_program" == "w3m" ]]; then + if [[ -z "$term_width" && "$image_program" == "w3m" ]]; then if type -p xdotool >/dev/null 2>&1; then current_window="$(xdotool getactivewindow)" source <(xdotool getwindowgeometry --shell "$current_window") @@ -2103,15 +2099,15 @@ get_term_size() { term_width="${term_size/ *}" term_height="${term_size/${term_width}}" else - term_width="0" + term_width=0 fi else - term_width="0" + term_width=0 fi fi # If the terminal size was found correctly. - if [[ "$term_width" ]] && ((term_width > 0)); then + if [[ "$term_width" ]] && ((term_width >= 1)); then clear zws="​ " fi @@ -2258,7 +2254,14 @@ display_image() { to_ascii() { # This function makes neofetch fallback to ascii mode. image_backend="ascii" + + # Print the ascii art. get_ascii 2>/dev/null + + # Move cursor next to ascii art. + printf "%b" "\033[${lines:-0}A\033[9999999D" + + # Log the error. err "$1" } @@ -2942,7 +2945,7 @@ old_options() { [[ "$speed_type" == "bios" ]] && err "Config: speed_type='bios' is deprecated, use speed_type='bios_limit' instead." # Ascii_logo_size was removed in 2.1.0. - [[ "$ascii_logo_size" ]] && err "Config: ascii_logo_size is deprecatedm use ascii_distro='{arch,crux,gentoo}_small' instead." + [[ "$ascii_logo_size" ]] && err "Config: ascii_logo_size is deprecated, use ascii_distro='{arch,crux,gentoo}_small' instead." } cache_uname() {