Merge pull request #616 from dylanaraps/image-rewrite
Image: Rewrite backend handling.
This commit is contained in:
commit
475dee93d8
129
config/config
129
config/config
|
@ -524,17 +524,69 @@ battery_display="off"
|
||||||
disk_display="off"
|
disk_display="off"
|
||||||
|
|
||||||
|
|
||||||
# Image Options
|
# Backend Settings
|
||||||
|
|
||||||
|
# Image backend.
|
||||||
|
#
|
||||||
|
# Default: 'ascii'
|
||||||
|
# Values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m'
|
||||||
|
# Flag: --backend
|
||||||
|
image_backend="ascii"
|
||||||
|
|
||||||
# Image Source
|
# Image Source
|
||||||
#
|
#
|
||||||
# Default: 'ascii'
|
# Which image or ascii file to display.
|
||||||
# Values: 'ascii', 'wallpaper', '/path/to/img', '/path/to/dir/', 'off'
|
|
||||||
# Flag: --image
|
|
||||||
#
|
#
|
||||||
# NOTE: Change this to 'wallpaper', '/path/to/img' or /path/to/dir/' to enable image mode. You can also launch neofetch with '--image wallpaper' and etc.
|
# Default: 'auto'
|
||||||
image_source="ascii"
|
# Values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
||||||
|
# Flag: --source
|
||||||
|
#
|
||||||
|
# NOTE: 'auto' will pick the best image source for whatever image backend is used.
|
||||||
|
# In ascii mode, distro ascii art will be used and in an image mode, your
|
||||||
|
# wallpaper will be used.
|
||||||
|
image_source="auto"
|
||||||
|
|
||||||
|
|
||||||
|
# Ascii Options
|
||||||
|
|
||||||
|
|
||||||
|
# Ascii distro
|
||||||
|
# Which distro's ascii art to display.
|
||||||
|
#
|
||||||
|
# Default: 'auto'
|
||||||
|
# Values: 'auto', 'distro_name'
|
||||||
|
# Flag: --ascii_distro
|
||||||
|
#
|
||||||
|
# NOTE: Arch and Ubuntu have 'old' logo variants.
|
||||||
|
# Change this to 'arch_old' or 'ubuntu_old' to use the old logos.
|
||||||
|
# NOTE: Ubuntu has flavor variants.
|
||||||
|
# Change this to 'Lubuntu', 'Xubuntu', 'Ubuntu-GNOME' or 'Ubuntu-Budgie' to use the flavors.
|
||||||
|
# NOTE: Arch, Crux and Gentoo have a smaller logo variant.
|
||||||
|
# Change this to 'arch_small', 'crux_small' or 'gentoo_small' to use the small logos.
|
||||||
|
ascii_distro="auto"
|
||||||
|
|
||||||
|
# Ascii Colors
|
||||||
|
#
|
||||||
|
# Default: 'distro'
|
||||||
|
# Values: 'distro', 'num' 'num' 'num' 'num' 'num' 'num'
|
||||||
|
# Flag: --ascii_colors
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ascii_colors=(distro) - Ascii is colored based on Distro colors.
|
||||||
|
# ascii_colors=(4 6 1 8 8 6) - Ascii is colored using these colors.
|
||||||
|
ascii_colors=(distro)
|
||||||
|
|
||||||
|
# Bold ascii logo
|
||||||
|
# Whether or not to bold the ascii logo.
|
||||||
|
#
|
||||||
|
# Default: 'on'
|
||||||
|
# Values: 'on', 'off'
|
||||||
|
# Flag: --ascii_bold
|
||||||
|
ascii_bold="on"
|
||||||
|
|
||||||
|
|
||||||
|
# Image Options
|
||||||
|
|
||||||
|
|
||||||
# Thumbnail directory
|
# Thumbnail directory
|
||||||
#
|
#
|
||||||
|
@ -542,22 +594,6 @@ image_source="ascii"
|
||||||
# Values: 'dir'
|
# Values: 'dir'
|
||||||
thumbnail_dir="${XDG_CACHE_HOME:-${HOME}/.cache}/thumbnails/neofetch"
|
thumbnail_dir="${XDG_CACHE_HOME:-${HOME}/.cache}/thumbnails/neofetch"
|
||||||
|
|
||||||
# w3m-img path
|
|
||||||
# Only works with the w3m backend.
|
|
||||||
#
|
|
||||||
# NOTE: Only change this if "neofetch -v" says that it "couldn't find w3m-img".
|
|
||||||
# Neofetch has a function that automatically finds w3m-img for you. It looks
|
|
||||||
# in the following directories:
|
|
||||||
# /usr/lib/w3m/w3mimgdisplay
|
|
||||||
# /usr/libexec/w3m/w3mimgdisplay
|
|
||||||
# /usr/lib64/w3m/w3mimgdisplay
|
|
||||||
# /usr/libexec64/w3m/w3mimgdisplay
|
|
||||||
# If w3m-img is installed elsewhere on your system, open an issue on the repo
|
|
||||||
# and I'll add it to the function inside the script. If w3m-img is installed
|
|
||||||
# in a non-standard way (in your home folder, etc) then change the variable
|
|
||||||
# below to the custom location. Otherwise, don't touch this.
|
|
||||||
w3m_img_path="/usr/lib/w3m/w3mimgdisplay"
|
|
||||||
|
|
||||||
# Crop mode
|
# Crop mode
|
||||||
#
|
#
|
||||||
# Default: 'normal'
|
# Default: 'normal'
|
||||||
|
@ -612,53 +648,6 @@ xoffset=0
|
||||||
background_color=
|
background_color=
|
||||||
|
|
||||||
|
|
||||||
# Ascii Options
|
|
||||||
|
|
||||||
|
|
||||||
# Default ascii image to use
|
|
||||||
# When this is set to distro it will use your
|
|
||||||
# distro's logo as the ascii.
|
|
||||||
#
|
|
||||||
# Default: 'distro'
|
|
||||||
# Values: 'distro', '/path/to/ascii_file'
|
|
||||||
# Flag: --ascii
|
|
||||||
ascii="distro"
|
|
||||||
|
|
||||||
# Ascii distro
|
|
||||||
# Which distro's ascii art to display.
|
|
||||||
#
|
|
||||||
# Default: 'auto'
|
|
||||||
# Values: 'auto', 'distro_name'
|
|
||||||
# Flag: --ascii_distro
|
|
||||||
#
|
|
||||||
# NOTE: Arch and Ubuntu have 'old' logo variants.
|
|
||||||
# Change this to 'arch_old' or 'ubuntu_old' to use the old logos.
|
|
||||||
# NOTE: Ubuntu has flavor variants.
|
|
||||||
# Change this to 'Lubuntu', 'Xubuntu', 'Ubuntu-GNOME' or 'Ubuntu-Budgie' to use the flavors.
|
|
||||||
# NOTE: Arch, Crux and Gentoo have a smaller logo variant.
|
|
||||||
# Change this to 'arch_small', 'crux_small' or 'gentoo_small' to use the small logos.
|
|
||||||
ascii_distro="auto"
|
|
||||||
|
|
||||||
# Ascii Colors
|
|
||||||
#
|
|
||||||
# Default: 'distro'
|
|
||||||
# Values: 'distro', 'num' 'num' 'num' 'num' 'num' 'num'
|
|
||||||
# Flag: --ascii_colors
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# ascii_colors=(distro) - Ascii is colored based on Distro colors.
|
|
||||||
# ascii_colors=(4 6 1 8 8 6) - Ascii is colored using these colors.
|
|
||||||
ascii_colors=(distro)
|
|
||||||
|
|
||||||
# Bold ascii logo
|
|
||||||
# Whether or not to bold the ascii logo.
|
|
||||||
#
|
|
||||||
# Default: 'on'
|
|
||||||
# Values: 'on', 'off'
|
|
||||||
# Flag: --ascii_bold
|
|
||||||
ascii_bold="on"
|
|
||||||
|
|
||||||
|
|
||||||
# Scrot Options
|
# Scrot Options
|
||||||
|
|
||||||
|
|
||||||
|
@ -714,7 +703,7 @@ scrot_name="neofetch-$(date +%F-%I-%M-%S-${RANDOM}).png"
|
||||||
image_host="teknik"
|
image_host="teknik"
|
||||||
|
|
||||||
|
|
||||||
# Config Options
|
# Misc Options
|
||||||
|
|
||||||
|
|
||||||
# Config version.
|
# Config version.
|
||||||
|
|
291
neofetch
291
neofetch
|
@ -1948,78 +1948,62 @@ get_cols() {
|
||||||
|
|
||||||
# IMAGES
|
# IMAGES
|
||||||
|
|
||||||
get_image_backend() {
|
image_backend() {
|
||||||
# This function determines which image backend to use
|
if [[ ! "$image_backend" =~ (off|ascii) ]]; then
|
||||||
# by checking for programs and etc.
|
if ! type -p convert >/dev/null 2>&1; then
|
||||||
|
image_backend="ascii"
|
||||||
|
err "Image: Imagemagick not found, falling back to ascii mode."
|
||||||
|
fi
|
||||||
|
|
||||||
# If the image source isn't "ascii" or "off".
|
|
||||||
if [[ ! "${image_source}" =~ ^(off|ascii)$ ]]; then
|
|
||||||
# If X isn't running force ascii mode here.
|
# If X isn't running force ascii mode here.
|
||||||
[[ -z "$DISPLAY" ]] && image_source="ascii"
|
[[ -z "$DISPLAY" ]] && image_backend="ascii"
|
||||||
|
|
||||||
# Fallback to ascii mode if imagemagick isn't installed.
|
|
||||||
type -p convert >/dev/null 2>&1 || image_source="ascii"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the image program.
|
case "${image_backend:-off}" in
|
||||||
get_image_program
|
"ascii") get_ascii ;;
|
||||||
|
"off") image_backend="off" ;;
|
||||||
|
|
||||||
# If image source is ascii fallback to ascii.
|
"caca" | "catimg" | "jp2a" | "iterm2" | "tycat" | "w3m")
|
||||||
if [[ "$image_source" == "ascii" ]]; then
|
get_image_source
|
||||||
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
|
|
||||||
"image")
|
|
||||||
case "$image_source" in
|
|
||||||
"wall"*) get_wallpaper 2>/dev/null ;;
|
|
||||||
"off") image_backend="off"; return ;;
|
|
||||||
*)
|
|
||||||
if [[ -d "$image_source" ]]; then
|
|
||||||
files=("${image_source%/}"/*.{png,jpg,jpeg})
|
|
||||||
printf -v image "%s" "${files[RANDOM % (${#files[@]} - 1)]}"
|
|
||||||
else
|
|
||||||
image="$image_source"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Fallback to ascii mode if image isn't a file.
|
|
||||||
if [[ ! -f "$image" ]]; then
|
if [[ ! -f "$image" ]]; then
|
||||||
to_ascii "Image: '$image' doesn't exist, falling back to ascii mode."
|
to_ascii "Image: '$image_source' doesn't exist, falling back to ascii mode."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_term_size
|
get_term_size
|
||||||
|
|
||||||
# Fallback to ascii mode if terminal size wasn't found.
|
if [[ "$term_width" ]] && ((term_width >= 1)); then
|
||||||
if [[ -z "$term_width" ]] || ((term_width == 0)); then
|
clear
|
||||||
to_ascii "Image: Failed to find terminal window size"
|
zws=" "
|
||||||
err "Image: Check the 'Images in the terminal' wiki page for more info"
|
else
|
||||||
|
unset image_program
|
||||||
|
to_ascii "Image: Failed to find terminal window size."
|
||||||
|
err "Image: Check the 'Images in the terminal' wiki page for more info,"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_image_size
|
get_image_size
|
||||||
make_thumbnail
|
make_thumbnail
|
||||||
|
display_image 2>/dev/null
|
||||||
# If the backend is still set to "image" after
|
|
||||||
# make_thumbnail(), then display the image.
|
|
||||||
[[ "$image_backend" == "image" ]] && display_image
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"ascii") get_ascii 2>/dev/null ;;
|
*)
|
||||||
|
err "Image: Unknown image backend specified '$image_backend'."
|
||||||
|
err "Image: Valid backends are: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m')"
|
||||||
|
err "Image: Falling back to ascii mode."
|
||||||
|
get_ascii
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Set cursor position next to ascii art.
|
# Set cursor position next image/ascii.
|
||||||
[[ "$image_backend" != "off" ]] && printf "%b" "\033[${lines:-0}A\033[9999999D"
|
[[ "$image_backend" != "off" ]] && printf "%b" "\033[${lines:-0}A\033[9999999D"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_ascii() {
|
get_ascii() {
|
||||||
if [[ ! -f "$ascii" || "$ascii" == "distro" ]]; then
|
if [[ ! -f "$image_source" || "$image_source" =~ (auto|ascii) ]]; then
|
||||||
# Fallback to distro ascii mode if custom ascii isn't found.
|
# Fallback to distro ascii mode if custom ascii isn't found.
|
||||||
[[ "$ascii" != "distro" && ! -f "$ascii" ]] && \
|
[[ ! "$image_source" =~ (auto|ascii) ]] && \
|
||||||
err "Ascii: Ascii file not found, using distro ascii."
|
err "Ascii: Ascii file not found, using distro ascii."
|
||||||
|
|
||||||
if [[ -d "/usr/share/neofetch/ascii/distro" ]]; then
|
if [[ -d "/usr/share/neofetch/ascii/distro" ]]; then
|
||||||
|
@ -2036,10 +2020,10 @@ get_ascii() {
|
||||||
ascii_dir="${script_dir}/ascii/distro"
|
ascii_dir="${script_dir}/ascii/distro"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ascii="${ascii_dir}/${ascii_file}"
|
image_source="${ascii_dir}/${ascii_file}"
|
||||||
|
|
||||||
# Fallback to no ascii mode if distro ascii isn't found.
|
# Fallback to no ascii mode if distro ascii isn't found.
|
||||||
[[ ! -f "$ascii" ]] && \
|
[[ ! -f "$image_source" ]] && \
|
||||||
{ to_off "Ascii: Failed to find distro ascii, falling back to no ascii mode."; return; }
|
{ to_off "Ascii: Failed to find distro ascii, falling back to no ascii mode."; return; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -2055,7 +2039,7 @@ get_ascii() {
|
||||||
line="${line//\\\\/\\}"
|
line="${line//\\\\/\\}"
|
||||||
((${#line} > ascii_length)) && ascii_length="${#line}"
|
((${#line} > ascii_length)) && ascii_length="${#line}"
|
||||||
((++lines))
|
((++lines))
|
||||||
done < "$ascii"
|
done < "$image_source"
|
||||||
|
|
||||||
# Colors.
|
# Colors.
|
||||||
print="${print//'${c1}'/$c1}"
|
print="${print//'${c1}'/$c1}"
|
||||||
|
@ -2073,39 +2057,26 @@ get_ascii() {
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
}
|
}
|
||||||
|
|
||||||
get_image_program() {
|
get_image_source() {
|
||||||
if [[ -n "$ITERM_PROFILE" ]]; then
|
case "$image_source" in
|
||||||
image_program="iterm2"
|
"auto" | "wall"*)
|
||||||
|
get_wallpaper 2>/dev/null
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ "$(tycat 2>/dev/null)" ]]; then
|
*)
|
||||||
image_program="tycat"
|
if [[ -d "$image_source" ]]; then
|
||||||
|
shopt -s nullglob
|
||||||
|
files=("${image_source%/}"/*.{png,jpg,jpeg,jpe,gif})
|
||||||
|
shopt -u nullglob
|
||||||
|
image="${files[RANDOM % ${#files[@]}]}"
|
||||||
|
|
||||||
else
|
else
|
||||||
image_program="w3m"
|
image="$image_source"
|
||||||
get_w3m_img_path
|
fi
|
||||||
fi
|
;;
|
||||||
}
|
esac
|
||||||
|
|
||||||
get_w3m_img_path() {
|
err "Image: Using image $image"
|
||||||
if [[ -x "$w3m_img_path" ]]; then
|
|
||||||
return
|
|
||||||
|
|
||||||
elif [[ -x "/usr/lib/w3m/w3mimgdisplay" ]]; then
|
|
||||||
w3m_img_path="/usr/lib/w3m/w3mimgdisplay"
|
|
||||||
|
|
||||||
elif [[ -x "/usr/libexec/w3m/w3mimgdisplay" ]]; then
|
|
||||||
w3m_img_path="/usr/libexec/w3m/w3mimgdisplay"
|
|
||||||
|
|
||||||
elif [[ -x "/usr/lib64/w3m/w3mimgdisplay" ]]; then
|
|
||||||
w3m_img_path="/usr/lib64/w3m/w3mimgdisplay"
|
|
||||||
|
|
||||||
elif [[ -x "/usr/libexec64/w3m/w3mimgdisplay" ]]; then
|
|
||||||
w3m_img_path="/usr/libexec64/w3m/w3mimgdisplay"
|
|
||||||
|
|
||||||
else
|
|
||||||
image_backend="ascii"
|
|
||||||
err "Image: w3m-img wasn't found on your system, falling back to ascii mode."
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_wallpaper() {
|
get_wallpaper() {
|
||||||
|
@ -2169,6 +2140,25 @@ get_wallpaper() {
|
||||||
[[ "${image/*\./}" == "xml" ]] && image=""
|
[[ "${image/*\./}" == "xml" ]] && image=""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_w3m_img_path() {
|
||||||
|
# Find w3m-img path.
|
||||||
|
if [[ -x "/usr/lib/w3m/w3mimgdisplay" ]]; then
|
||||||
|
w3m_img_path="/usr/lib/w3m/w3mimgdisplay"
|
||||||
|
|
||||||
|
elif [[ -x "/usr/libexec/w3m/w3mimgdisplay" ]]; then
|
||||||
|
w3m_img_path="/usr/libexec/w3m/w3mimgdisplay"
|
||||||
|
|
||||||
|
elif [[ -x "/usr/lib64/w3m/w3mimgdisplay" ]]; then
|
||||||
|
w3m_img_path="/usr/lib64/w3m/w3mimgdisplay"
|
||||||
|
|
||||||
|
elif [[ -x "/usr/libexec64/w3m/w3mimgdisplay" ]]; then
|
||||||
|
w3m_img_path="/usr/libexec64/w3m/w3mimgdisplay"
|
||||||
|
|
||||||
|
else
|
||||||
|
err "Image: w3m-img wasn't found on your system"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
get_term_size() {
|
get_term_size() {
|
||||||
# This functions gets the current window size in
|
# This functions gets the current window size in
|
||||||
# pixels.
|
# pixels.
|
||||||
|
@ -2237,12 +2227,6 @@ get_term_size() {
|
||||||
term_width=0
|
term_width=0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the terminal size was found correctly.
|
|
||||||
if [[ "$term_width" ]] && ((term_width >= 1)); then
|
|
||||||
clear
|
|
||||||
zws=" "
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_image_size() {
|
get_image_size() {
|
||||||
|
@ -2364,13 +2348,20 @@ make_thumbnail() {
|
||||||
}
|
}
|
||||||
|
|
||||||
display_image() {
|
display_image() {
|
||||||
case "$image_program" in
|
case "$image_backend" in
|
||||||
"w3m")
|
"caca")
|
||||||
# Add a tiny delay to fix issues with images not
|
img2txt -W "$((width / font_width)))" -H "$((height / font_height))" --gamma=0.6 "$image" || to_off "Image: catimg failed to display the image."
|
||||||
# appearing in specific terminal emulators.
|
zws=
|
||||||
sleep 0.05
|
;;
|
||||||
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."
|
"catimg")
|
||||||
|
catimg -w "$((width * 2 / font_width))" -r 0 "$image" || to_off "Image: catimg failed to display the image."
|
||||||
|
zws=
|
||||||
|
;;
|
||||||
|
|
||||||
|
"jp2a")
|
||||||
|
jp2a --width="$((width / font_width))" --colors "$image" || to_off "Image: jp2a failed to display the image."
|
||||||
|
zws=
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"iterm2")
|
"iterm2")
|
||||||
|
@ -2378,31 +2369,41 @@ display_image() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"tycat")
|
"tycat")
|
||||||
tycat "$image" || to_off "Images: tycat failed to display the image."
|
tycat "$image" || to_off "Image: tycat failed to display the image."
|
||||||
|
;;
|
||||||
|
|
||||||
|
"w3m")
|
||||||
|
get_w3m_img_path
|
||||||
|
|
||||||
|
# Add a tiny delay to fix issues with images not
|
||||||
|
# appearing in specific terminal emulators.
|
||||||
|
sleep 0.05
|
||||||
|
printf "%b\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$image\n4;\n3;" |\
|
||||||
|
"${w3m_img_path:-false}" -bg "$background_color" >/dev/null & 2>&1 || to_off "Image: w3m-img failed to display the image."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
to_ascii() {
|
to_ascii() {
|
||||||
|
# Log the error.
|
||||||
|
err "$1"
|
||||||
|
|
||||||
# This function makes neofetch fallback to ascii mode.
|
# This function makes neofetch fallback to ascii mode.
|
||||||
image_backend="ascii"
|
image_backend="ascii"
|
||||||
|
|
||||||
# Print the ascii art.
|
# Print the ascii art.
|
||||||
get_ascii 2>/dev/null
|
get_ascii 2>/dev/null
|
||||||
|
|
||||||
# Move cursor next to ascii art.
|
# Set cursor position next image/ascii.
|
||||||
printf "%b" "\033[${lines:-0}A\033[9999999D"
|
printf "%b" "\033[${lines:-0}A\033[9999999D"
|
||||||
|
|
||||||
# Log the error.
|
|
||||||
err "$1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_off() {
|
to_off() {
|
||||||
# This function makes neofetch fallback to off mode.
|
# This function makes neofetch fallback to off mode.
|
||||||
|
err "$1"
|
||||||
image_backend="off"
|
image_backend="off"
|
||||||
text_padding=
|
text_padding=
|
||||||
zws=
|
zws=
|
||||||
err "$1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# SCREENSHOT
|
# SCREENSHOT
|
||||||
|
@ -2555,7 +2556,7 @@ get_underline() {
|
||||||
|
|
||||||
get_line_break() {
|
get_line_break() {
|
||||||
# Print it directly.
|
# Print it directly.
|
||||||
printf "%s\n" "${zws} "
|
printf "%s\n" "${zws}"
|
||||||
|
|
||||||
# Calculate info height.
|
# Calculate info height.
|
||||||
((++info_height))
|
((++info_height))
|
||||||
|
@ -3411,13 +3412,14 @@ get_term_padding() {
|
||||||
|
|
||||||
dynamic_prompt() {
|
dynamic_prompt() {
|
||||||
case "$image_backend" in
|
case "$image_backend" in
|
||||||
"image")
|
"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
|
||||||
|
@ -3714,33 +3716,23 @@ BARS:
|
||||||
Possible values: bar, infobar, barinfo, off
|
Possible values: bar, infobar, barinfo, off
|
||||||
--disk_display mode Bar mode.
|
--disk_display mode Bar mode.
|
||||||
Possible values: bar, infobar, barinfo, off
|
Possible values: bar, infobar, barinfo, off
|
||||||
IMAGE:
|
|
||||||
--image type Image source. Where and what image we display.
|
|
||||||
Possible values: wall, ascii,
|
|
||||||
/path/to/img, /path/to/dir/, off
|
|
||||||
--size 00px | --size 00% How to size the image.
|
|
||||||
Possible values: auto, 00px, 00%, none
|
|
||||||
--crop_mode mode Which crop mode to use
|
|
||||||
Possible values: normal, fit, fill
|
|
||||||
--crop_offset value Change the crop offset for normal mode.
|
|
||||||
Possible values: northwest, north, northeast,
|
|
||||||
west, center, east, southwest, south, southeast
|
|
||||||
|
|
||||||
--xoffset px How close the image will be to the left edge of the
|
IMAGE BACKEND:
|
||||||
window. This only works with w3m.
|
--backend backend Which image backend to use.
|
||||||
--yoffset px How close the image will be to the top edge of the
|
Possible values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m'
|
||||||
window. This only works with w3m.
|
--source source Which image or ascii file to use.
|
||||||
--bg_color color Background color to display behind transparent image.
|
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
||||||
This only works with w3m.
|
--ascii source Shortcut to use 'ascii' backend.
|
||||||
--gap num Gap between image and text.
|
--caca source Shortcut to use 'caca' backend.
|
||||||
|
--catimg source Shortcut to use 'catimg' backend.
|
||||||
|
--iterm2 source Shortcut to use 'iterm2' backend.
|
||||||
|
--tycat source Shortcut to use 'tycat' backend.
|
||||||
|
--w3m source Shortcut to use 'w3m' backend.
|
||||||
|
--off Shortcut to use 'off' backend.
|
||||||
|
|
||||||
NOTE: --gap can take a negative value which will move the text closer to the left side.
|
NOTE: 'source; can be any of the following: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
||||||
|
|
||||||
--clean Delete cached files and thumbnails.
|
|
||||||
|
|
||||||
ASCII:
|
ASCII:
|
||||||
--ascii value Where to get the ascii from, Possible values:
|
|
||||||
distro, /path/to/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
|
||||||
--ascii_distro distro Which Distro's ascii art to print
|
--ascii_distro distro Which Distro's ascii art to print
|
||||||
|
|
||||||
|
@ -3759,6 +3751,29 @@ ASCII:
|
||||||
--ascii_bold on/off Whether or not to bold the ascii logo.
|
--ascii_bold on/off Whether or not to bold the ascii logo.
|
||||||
-L, --logo Hide the info text and only show the ascii logo.
|
-L, --logo Hide the info text and only show the ascii logo.
|
||||||
|
|
||||||
|
Possible values: bar, infobar, barinfo, off
|
||||||
|
|
||||||
|
IMAGE:
|
||||||
|
--size 00px | --size 00% How to size the image.
|
||||||
|
Possible values: auto, 00px, 00%, none
|
||||||
|
--crop_mode mode Which crop mode to use
|
||||||
|
Takes the values: normal, fit, fill
|
||||||
|
--crop_offset value Change the crop offset for normal mode.
|
||||||
|
Possible values: northwest, north, northeast,
|
||||||
|
west, center, east, southwest, south, southeast
|
||||||
|
|
||||||
|
--xoffset px How close the image will be to the left edge of the
|
||||||
|
window. This only works with w3m.
|
||||||
|
--yoffset px How close the image will be to the top edge of the
|
||||||
|
window. This only works with w3m.
|
||||||
|
--bg_color color Background color to display behind transparent image.
|
||||||
|
This only works with w3m.
|
||||||
|
--gap num Gap between image and text.
|
||||||
|
|
||||||
|
NOTE: --gap can take a negative value which will move the text closer to the left side.
|
||||||
|
|
||||||
|
--clean Delete cached files and thumbnails.
|
||||||
|
|
||||||
SCREENSHOT:
|
SCREENSHOT:
|
||||||
-s, --scrot /path/to/img Take a screenshot, if path is left empty the screen-
|
-s, --scrot /path/to/img Take a screenshot, if path is left empty the screen-
|
||||||
shot function will use \$scrot_dir and \$scrot_name.
|
shot function will use \$scrot_dir and \$scrot_name.
|
||||||
|
@ -3814,7 +3829,7 @@ exit 1
|
||||||
|
|
||||||
get_args() {
|
get_args() {
|
||||||
# Check the commandline flags early for '--config'.
|
# Check the commandline flags early for '--config'.
|
||||||
[[ "$@" =~ --config ]] || get_user_config 2>/dev/null
|
[[ "$@" != *--config* ]] && get_user_config 2>/dev/null
|
||||||
|
|
||||||
while [[ "$1" ]]; do
|
while [[ "$1" ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -3910,12 +3925,18 @@ get_args() {
|
||||||
"--battery_display") battery_display="$2" ;;
|
"--battery_display") battery_display="$2" ;;
|
||||||
"--disk_display") disk_display="$2" ;;
|
"--disk_display") disk_display="$2" ;;
|
||||||
|
|
||||||
# Image
|
# Image backend
|
||||||
"--image")
|
"--backend") image_backend="$2" ;;
|
||||||
image_source="$2"
|
"--source") image_source="$2" ;;
|
||||||
case "$2" in "-"* | "" | "ascii") image_backend="ascii" ;; esac
|
"--ascii" | "--caca" | "--catimg" | "--jp2a" | "--iterm2" | "--off" | "--tycat" | "--w3m")
|
||||||
|
image_backend="${1/--}"
|
||||||
|
case "$2" in
|
||||||
|
"-"* | "") ;;
|
||||||
|
*) image_source="$2" ;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
# Image options
|
||||||
"--image_size" | "--size") image_size="$2" ;;
|
"--image_size" | "--size") image_size="$2" ;;
|
||||||
"--crop_mode") crop_mode="$2" ;;
|
"--crop_mode") crop_mode="$2" ;;
|
||||||
"--crop_offset") crop_offset="$2" ;;
|
"--crop_offset") crop_offset="$2" ;;
|
||||||
|
@ -3930,13 +3951,6 @@ get_args() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Ascii
|
|
||||||
"--ascii")
|
|
||||||
image_backend="ascii"
|
|
||||||
ascii="$2"
|
|
||||||
case "$2" in "-"* | "") ascii="distro" ;; esac
|
|
||||||
;;
|
|
||||||
|
|
||||||
"--ascii_colors")
|
"--ascii_colors")
|
||||||
unset ascii_colors
|
unset ascii_colors
|
||||||
for arg in "$2" "$3" "$4" "$5" "$6" "$7"; do
|
for arg in "$2" "$3" "$4" "$5" "$6" "$7"; do
|
||||||
|
@ -4008,7 +4022,8 @@ main() {
|
||||||
printf "\033[?25l\033[?7l"
|
printf "\033[?25l\033[?7l"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_image_backend
|
# get_image_backend
|
||||||
|
image_backend
|
||||||
old_functions
|
old_functions
|
||||||
get_cache_dir
|
get_cache_dir
|
||||||
print_info 2>/dev/null
|
print_info 2>/dev/null
|
||||||
|
@ -4016,7 +4031,7 @@ main() {
|
||||||
|
|
||||||
# w3m-img: Draw the image a second time to fix
|
# w3m-img: Draw the image a second time to fix
|
||||||
# rendering issues in specific terminal emulators.
|
# rendering issues in specific terminal emulators.
|
||||||
[[ "$image_backend" == "image" && "$image_program" == "w3m" ]] && display_image
|
[[ "$image_program" == *w3m* ]] && display_image 2>/dev/null
|
||||||
|
|
||||||
# Take a screenshot.
|
# Take a screenshot.
|
||||||
[[ "$scrot" == "on" ]] && take_scrot
|
[[ "$scrot" == "on" ]] && take_scrot
|
||||||
|
|
95
neofetch.1
95
neofetch.1
|
@ -171,12 +171,66 @@ Possible values: bar, infobar, barinfo, off
|
||||||
\fB\-\-disk_display\fR mode
|
\fB\-\-disk_display\fR mode
|
||||||
Bar mode.
|
Bar mode.
|
||||||
Possible values: bar, infobar, barinfo, off
|
Possible values: bar, infobar, barinfo, off
|
||||||
.SS "IMAGE:"
|
.SS "IMAGE BACKEND:"
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-image\fR type
|
\fB\-\-backend\fR backend
|
||||||
Image source. Where and what image we display.
|
Which image backend to use.
|
||||||
Possible values: wall, ascii,
|
Possible values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m'
|
||||||
\fI\,/path/to/img\/\fP, /path/to/dir/, off
|
.TP
|
||||||
|
\fB\-\-source\fR source
|
||||||
|
Which image or ascii file to use.
|
||||||
|
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
||||||
|
.TP
|
||||||
|
\fB\-\-ascii\fR
|
||||||
|
source Shortcut to use 'ascii' backend.
|
||||||
|
.TP
|
||||||
|
\fB\-\-caca\fR
|
||||||
|
source Shortcut to use 'caca' backend.
|
||||||
|
.TP
|
||||||
|
\fB\-\-catimg\fR
|
||||||
|
source Shortcut to use 'catimg' backend.
|
||||||
|
.TP
|
||||||
|
\fB\-\-iterm2\fR
|
||||||
|
source Shortcut to use 'iterm2' backend.
|
||||||
|
.TP
|
||||||
|
\fB\-\-tycat\fR
|
||||||
|
source Shortcut to use 'tycat' backend.
|
||||||
|
.TP
|
||||||
|
\fB\-\-w3m\fR
|
||||||
|
source Shortcut to use 'w3m' backend.
|
||||||
|
.TP
|
||||||
|
\fB\-\-off\fR
|
||||||
|
Shortcut to use 'off' backend.
|
||||||
|
.IP
|
||||||
|
NOTE: 'source; can be any of the following: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
||||||
|
.SS "ASCII:"
|
||||||
|
.TP
|
||||||
|
\fB\-\-ascii_colors\fR x x x x x x
|
||||||
|
Colors to print the ascii art
|
||||||
|
.TP
|
||||||
|
\fB\-\-ascii_distro\fR distro
|
||||||
|
Which Distro's ascii art to print
|
||||||
|
.IP
|
||||||
|
NOTE: Arch and Ubuntu have 'old' logo variants.
|
||||||
|
.IP
|
||||||
|
NOTE: Use 'arch_old' or 'ubuntu_old' to use the old logos.
|
||||||
|
.IP
|
||||||
|
NOTE: Ubuntu has flavor variants.
|
||||||
|
.IP
|
||||||
|
NOTE: Change this to 'Lubuntu', 'Xubuntu', 'Ubuntu\-GNOME', 'Ubuntu\-Studio' or 'Ubuntu\-Budgie' to use the flavors.
|
||||||
|
.IP
|
||||||
|
NOTE: Alpine, Arch, Crux, Gentoo, OpenBSD, and Void have a smaller logo variant.
|
||||||
|
.IP
|
||||||
|
NOTE: Change this to 'alpine_small', 'arch_small', 'crux_small', 'gentoo_small', 'openbsd_small', and 'void_small' to use the small logos.
|
||||||
|
.TP
|
||||||
|
\fB\-\-ascii_bold\fR on/off
|
||||||
|
Whether or not to bold the ascii logo.
|
||||||
|
.TP
|
||||||
|
\fB\-L\fR, \fB\-\-logo\fR
|
||||||
|
Hide the info text and only show the ascii logo.
|
||||||
|
.IP
|
||||||
|
Possible values: bar, infobar, barinfo, off
|
||||||
|
.SS "IMAGE:"
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-size\fR 00px | \fB\-\-size\fR 00%
|
\fB\-\-size\fR 00px | \fB\-\-size\fR 00%
|
||||||
How to size the image.
|
How to size the image.
|
||||||
|
@ -184,7 +238,7 @@ Possible values: auto, 00px, 00%, none
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-crop_mode\fR mode
|
\fB\-\-crop_mode\fR mode
|
||||||
Which crop mode to use
|
Which crop mode to use
|
||||||
Possible values: normal, fit, fill
|
Takes the values: normal, fit, fill
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-crop_offset\fR value
|
\fB\-\-crop_offset\fR value
|
||||||
Change the crop offset for normal mode.
|
Change the crop offset for normal mode.
|
||||||
|
@ -210,35 +264,6 @@ NOTE: \fB\-\-gap\fR can take a negative value which will move the text closer to
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-clean\fR
|
\fB\-\-clean\fR
|
||||||
Delete cached files and thumbnails.
|
Delete cached files and thumbnails.
|
||||||
.SS "ASCII:"
|
|
||||||
.TP
|
|
||||||
\fB\-\-ascii\fR value
|
|
||||||
Where to get the ascii from, Possible values:
|
|
||||||
distro, \fI\,/path/to/ascii\/\fP
|
|
||||||
.TP
|
|
||||||
\fB\-\-ascii_colors\fR x x x x x x
|
|
||||||
Colors to print the ascii art
|
|
||||||
.TP
|
|
||||||
\fB\-\-ascii_distro\fR distro
|
|
||||||
Which Distro's ascii art to print
|
|
||||||
.IP
|
|
||||||
NOTE: Arch and Ubuntu have 'old' logo variants.
|
|
||||||
.IP
|
|
||||||
NOTE: Use 'arch_old' or 'ubuntu_old' to use the old logos.
|
|
||||||
.IP
|
|
||||||
NOTE: Ubuntu has flavor variants.
|
|
||||||
.IP
|
|
||||||
NOTE: Change this to 'Lubuntu', 'Xubuntu', 'Ubuntu\-GNOME', 'Ubuntu\-Studio' or 'Ubuntu\-Budgie' to use the flavors.
|
|
||||||
.IP
|
|
||||||
NOTE: Alpine, Arch, Crux, Gentoo, OpenBSD, and Void have a smaller logo variant.
|
|
||||||
.IP
|
|
||||||
NOTE: Change this to 'alpine_small', 'arch_small', 'crux_small', 'gentoo_small', 'openbsd_small', and 'void_small' to use the small logos.
|
|
||||||
.TP
|
|
||||||
\fB\-\-ascii_bold\fR on/off
|
|
||||||
Whether or not to bold the ascii logo.
|
|
||||||
.TP
|
|
||||||
\fB\-L\fR, \fB\-\-logo\fR
|
|
||||||
Hide the info text and only show the ascii logo.
|
|
||||||
.SS "SCREENSHOT:"
|
.SS "SCREENSHOT:"
|
||||||
.TP
|
.TP
|
||||||
\fB\-s\fR, \fB\-\-scrot\fR \fI\,/path/to/img\/\fP
|
\fB\-s\fR, \fB\-\-scrot\fR \fI\,/path/to/img\/\fP
|
||||||
|
|
Reference in New Issue