Images: Add support for catimg and caca
This commit is contained in:
parent
d35ecf826a
commit
d8712286f8
|
@ -529,7 +529,7 @@ disk_display="off"
|
||||||
# Image backend.
|
# Image backend.
|
||||||
#
|
#
|
||||||
# Default: 'ascii'
|
# Default: 'ascii'
|
||||||
# Values: 'ascii', 'w3m', 'iterm2', 'tycat', 'off'
|
# Values: 'ascii', 'caca', 'catimg', 'iterm2', 'off', 'tycat', 'w3m'
|
||||||
# Flag: --image_backend
|
# Flag: --image_backend
|
||||||
image_backend="ascii"
|
image_backend="ascii"
|
||||||
|
|
||||||
|
|
65
neofetch
65
neofetch
|
@ -1954,7 +1954,7 @@ image_backend() {
|
||||||
"ascii") get_ascii ;;
|
"ascii") get_ascii ;;
|
||||||
"off") image_backend="off" ;;
|
"off") image_backend="off" ;;
|
||||||
|
|
||||||
"iterm2" | "w3m" | "tycat")
|
"iterm2" | "w3m" | "tycat" | "catimg" | "caca")
|
||||||
get_image_source
|
get_image_source
|
||||||
|
|
||||||
if [[ ! -f "$image" ]]; then
|
if [[ ! -f "$image" ]]; then
|
||||||
|
@ -1962,16 +1962,6 @@ image_backend() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_image_program
|
|
||||||
|
|
||||||
if type -p "$image_program" >/dev/null 2>&1; then
|
|
||||||
err "Image: Drawing images using '$image_program'."
|
|
||||||
else
|
|
||||||
to_ascii "Image: Failed to find image program '$image_program'."
|
|
||||||
err "Image: Falling back to ascii mode."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
get_term_size
|
get_term_size
|
||||||
|
|
||||||
if [[ "$term_width" ]] && ((term_width >= 1)); then
|
if [[ "$term_width" ]] && ((term_width >= 1)); then
|
||||||
|
@ -1995,6 +1985,7 @@ image_backend() {
|
||||||
err "Image: Falling back to ascii mode."
|
err "Image: Falling back to ascii mode."
|
||||||
get_ascii
|
get_ascii
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Set cursor position next image/ascii.
|
# Set cursor position next image/ascii.
|
||||||
|
@ -2139,30 +2130,22 @@ get_wallpaper() {
|
||||||
[[ "${image/*\./}" == "xml" ]] && image=""
|
[[ "${image/*\./}" == "xml" ]] && image=""
|
||||||
}
|
}
|
||||||
|
|
||||||
get_image_program() {
|
get_w3m_img_path() {
|
||||||
if [[ -n "$ITERM_PROFILE" ]]; then
|
|
||||||
image_program="iterm2"
|
|
||||||
|
|
||||||
elif [[ "$(tycat 2>/dev/null)" ]]; then
|
|
||||||
image_program="tycat"
|
|
||||||
|
|
||||||
else
|
|
||||||
# Find w3m-img path.
|
# Find w3m-img path.
|
||||||
if [[ -x "$w3m_img_path" ]]; then
|
if [[ -x "$w3m_img_path" ]]; then
|
||||||
image_program="$w3m_img_path"
|
w3m_img_path="$w3m_img_path"
|
||||||
|
|
||||||
elif [[ -x "/usr/lib/w3m/w3mimgdisplay" ]]; then
|
elif [[ -x "/usr/lib/w3m/w3mimgdisplay" ]]; then
|
||||||
image_program="/usr/lib/w3m/w3mimgdisplay"
|
w3m_img_path="/usr/lib/w3m/w3mimgdisplay"
|
||||||
|
|
||||||
elif [[ -x "/usr/libexec/w3m/w3mimgdisplay" ]]; then
|
elif [[ -x "/usr/libexec/w3m/w3mimgdisplay" ]]; then
|
||||||
image_program="/usr/libexec/w3m/w3mimgdisplay"
|
w3m_img_path="/usr/libexec/w3m/w3mimgdisplay"
|
||||||
|
|
||||||
elif [[ -x "/usr/lib64/w3m/w3mimgdisplay" ]]; then
|
elif [[ -x "/usr/lib64/w3m/w3mimgdisplay" ]]; then
|
||||||
image_program="/usr/lib64/w3m/w3mimgdisplay"
|
w3m_img_path="/usr/lib64/w3m/w3mimgdisplay"
|
||||||
|
|
||||||
elif [[ -x "/usr/libexec64/w3m/w3mimgdisplay" ]]; then
|
elif [[ -x "/usr/libexec64/w3m/w3mimgdisplay" ]]; then
|
||||||
image_program="/usr/libexec64/w3m/w3mimgdisplay"
|
w3m_img_path="/usr/libexec64/w3m/w3mimgdisplay"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2355,14 +2338,15 @@ make_thumbnail() {
|
||||||
}
|
}
|
||||||
|
|
||||||
display_image() {
|
display_image() {
|
||||||
image_program="catimg"
|
case "$image_backend" in
|
||||||
case "$image_program" in
|
"w3m")
|
||||||
*"w3m"*)
|
get_w3m_img_path
|
||||||
|
|
||||||
# Add a tiny delay to fix issues with images not
|
# Add a tiny delay to fix issues with images not
|
||||||
# appearing in specific terminal emulators.
|
# appearing in specific terminal emulators.
|
||||||
sleep 0.05
|
sleep 0.05
|
||||||
printf "%b\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$image\n4;\n3;" |\
|
printf "%b\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$image\n4;\n3;" |\
|
||||||
"$w3m_img_path" -bg "$background_color" >/dev/null & 2>&1 || to_off "Images: w3m-img failed to display the image."
|
"${w3m_img_path:-false}" -bg "$background_color" >/dev/null & 2>&1 || to_off "Images: w3m-img failed to display the image."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"iterm2")
|
"iterm2")
|
||||||
|
@ -3415,13 +3399,14 @@ get_term_padding() {
|
||||||
|
|
||||||
dynamic_prompt() {
|
dynamic_prompt() {
|
||||||
case "$image_backend" in
|
case "$image_backend" in
|
||||||
"iterm2" | "w3m" | "tycat")
|
"ascii") ;;
|
||||||
|
"off") return ;;
|
||||||
|
*)
|
||||||
get_term_padding 2>/dev/null
|
get_term_padding 2>/dev/null
|
||||||
|
|
||||||
# Calculate image height in terminal cells.
|
# Calculate image height in terminal cells.
|
||||||
lines="$(((border * 2 + height + yoffset) / font_height))"
|
lines="$(((border * 2 + height + yoffset) / font_height))"
|
||||||
;;
|
;;
|
||||||
"off") return ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# If the info is higher than the ascii/image place the prompt
|
# If the info is higher than the ascii/image place the prompt
|
||||||
|
@ -3721,14 +3706,16 @@ BARS:
|
||||||
|
|
||||||
IMAGE BACKEND:
|
IMAGE BACKEND:
|
||||||
--image_backend backend Which image backend to use.
|
--image_backend backend Which image backend to use.
|
||||||
Possible values: 'ascii', 'w3m', 'iterm2', 'tycat', 'off'
|
Possible values: 'ascii', 'caca', 'catimg', 'iterm2', 'off', 'tycat', 'w3m'
|
||||||
--image_source source Which image or ascii file to use.
|
--image_source source Which image or ascii file to use.
|
||||||
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
||||||
--w3m Shortcut to use 'w3m' backend.
|
|
||||||
--iterm2 Shortcut to use 'iterm2' backend.
|
|
||||||
--tycat Shortcut to use 'tycat' backend.
|
|
||||||
--ascii Shortcut to use 'ascii' backend.
|
--ascii Shortcut to use 'ascii' backend.
|
||||||
|
--caca Shortcut to use 'caca' backend.
|
||||||
|
--catimg Shortcut to use 'catimg' backend.
|
||||||
|
--iterm2 Shortcut to use 'iterm2' backend.
|
||||||
--off Shortcut to use 'off' backend.
|
--off Shortcut to use 'off' backend.
|
||||||
|
--tycat Shortcut to use 'tycat' backend.
|
||||||
|
--w3m Shortcut to use 'w3m' backend.
|
||||||
|
|
||||||
ASCII:
|
ASCII:
|
||||||
--ascii_colors x x x x x x Colors to print the ascii art
|
--ascii_colors x x x x x x Colors to print the ascii art
|
||||||
|
@ -3926,11 +3913,13 @@ get_args() {
|
||||||
# Image backend
|
# Image backend
|
||||||
"--image_backend") image_backend="$2" ;;
|
"--image_backend") image_backend="$2" ;;
|
||||||
"--image_source") image_source="$2" ;;
|
"--image_source") image_source="$2" ;;
|
||||||
"--w3m") image_backend="w3m" ;;
|
|
||||||
"--iterm2") image_backend="iterm2" ;;
|
|
||||||
"--tycat") image_backend="tycat" ;;
|
|
||||||
"--ascii") image_backend="ascii" ;;
|
"--ascii") image_backend="ascii" ;;
|
||||||
|
"--caca") image_backend="caca" ;;
|
||||||
|
"--catimg") image_backend="catimg" ;;
|
||||||
|
"--iterm2") image_backend="iterm2" ;;
|
||||||
"--off") image_backend="off" ;;
|
"--off") image_backend="off" ;;
|
||||||
|
"--tycat") image_backend="tycat" ;;
|
||||||
|
"--w3m") image_backend="w3m" ;;
|
||||||
|
|
||||||
# Image options
|
# Image options
|
||||||
"--image_size" | "--size") image_size="$2" ;;
|
"--image_size" | "--size") image_size="$2" ;;
|
||||||
|
|
22
neofetch.1
22
neofetch.1
|
@ -175,26 +175,32 @@ Takes: bar, infobar, barinfo, off
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-image_backend\fR backend
|
\fB\-\-image_backend\fR backend
|
||||||
Which image backend to use.
|
Which image backend to use.
|
||||||
Possible values: 'ascii', 'w3m', 'iterm2', 'tycat', 'off'
|
Possible values: 'ascii', 'caca', 'catimg', 'iterm2', 'off', 'tycat', 'w3m'
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-image_source\fR source
|
\fB\-\-image_source\fR source
|
||||||
Which image or ascii file to use.
|
Which image or ascii file to use.
|
||||||
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-w3m\fR
|
\fB\-\-ascii\fR
|
||||||
Shortcut to use 'w3m' backend.
|
Shortcut to use 'ascii' backend.
|
||||||
|
.TP
|
||||||
|
\fB\-\-caca\fR
|
||||||
|
Shortcut to use 'caca' backend.
|
||||||
|
.TP
|
||||||
|
\fB\-\-catimg\fR
|
||||||
|
Shortcut to use 'catimg' backend.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-iterm2\fR
|
\fB\-\-iterm2\fR
|
||||||
Shortcut to use 'iterm2' backend.
|
Shortcut to use 'iterm2' backend.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-off\fR
|
||||||
|
Shortcut to use 'off' backend.
|
||||||
|
.TP
|
||||||
\fB\-\-tycat\fR
|
\fB\-\-tycat\fR
|
||||||
Shortcut to use 'tycat' backend.
|
Shortcut to use 'tycat' backend.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-ascii\fR
|
\fB\-\-w3m\fR
|
||||||
Shortcut to use 'ascii' backend.
|
Shortcut to use 'w3m' backend.
|
||||||
.TP
|
|
||||||
\fB\-\-off\fR
|
|
||||||
Shortcut to use 'off' backend.
|
|
||||||
.SS "ASCII:"
|
.SS "ASCII:"
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-ascii_colors\fR x x x x x x
|
\fB\-\-ascii_colors\fR x x x x x x
|
||||||
|
|
Reference in New Issue