ascii: Added support for command output

This commit is contained in:
Dylan Araps 2019-01-07 18:04:25 +02:00
parent a52115b364
commit 1b356da175
1 changed files with 6 additions and 3 deletions

View File

@ -3418,8 +3418,9 @@ image_backend() {
get_ascii() { get_ascii() {
if [[ -f "$image_source" && ! "$image_source" =~ (png|jpg|jpeg|jpe|svg|gif) ]]; then if [[ -f "$image_source" && ! "$image_source" =~ (png|jpg|jpeg|jpe|svg|gif) ]]; then
ascii_data="$(< "$image_source")" ascii_data="$(< "$image_source")"
else
err "Ascii: Ascii file not found, using distro ascii." elif [[ "$image_source" != "auto" ]]; then
ascii_data="$image_source"
fi fi
# Set locale to get correct padding. # Set locale to get correct padding.
@ -3430,6 +3431,9 @@ get_ascii() {
((++lines,${#line}>ascii_length)) && ascii_length="${#line}" ((++lines,${#line}>ascii_length)) && ascii_length="${#line}"
done <<< "${ascii_data//\$\{??\}}" done <<< "${ascii_data//\$\{??\}}"
# Fallback if file not found.
((lines==1)) && { image_source="auto"; get_distro_ascii; get_ascii; return; }
# Colors. # Colors.
ascii_data="${ascii_data//\$\{c1\}/$c1}" ascii_data="${ascii_data//\$\{c1\}/$c1}"
ascii_data="${ascii_data//\$\{c2\}/$c2}" ascii_data="${ascii_data//\$\{c2\}/$c2}"
@ -4595,7 +4599,6 @@ get_args() {
"--ascii_distro") "--ascii_distro")
image_backend="ascii" image_backend="ascii"
ascii_distro="$2" ascii_distro="$2"
case "$2" in "-"* | "") ascii_distro="$distro" ;; esac
;; ;;
"--ascii_bold") ascii_bold="$2" ;; "--ascii_bold") ascii_bold="$2" ;;