Compare commits

..

1 Commits

Author SHA1 Message Date
Dylan Araps
5234e76007 general: Use $HOSTTYPE instead of uname. 2018-05-31 06:38:39 +10:00

View File

@@ -781,29 +781,19 @@ EOF
get_os() {
# $kernel_name is set in a function called cache_uname and is
# just the output of "uname -s".
case "$OSTYPE" in
"aix"*) os="AIX" ;;
"darwin"*) os="$(sw_vers -productName)" ;;
"haiku"*) os="Haiku" ;;
"irix"*) os="IRIX" ;;
"minix"*) os="MINIX" ;;
"mint"*) os="FreeMiNT" ;;
"solaris"*) os="Solaris" ;;
"linux"* | "gnu"*)
os="Linux"
;;
*"bsd"* | "dragonfly"* | "bitrig"*)
os="BSD"
;;
"cygwin"* | "msys"* | "mingw"* | "win32"*)
os="Windows"
;;
case "$kernel_name" in
"Linux" | "GNU"*) os="Linux" ;;
"Darwin") os="$(sw_vers -productName)" ;;
*"BSD" | "DragonFly" | "Bitrig") os="BSD" ;;
"CYGWIN"* | "MSYS"* | "MINGW"*) os="Windows" ;;
"SunOS") os="Solaris" ;;
"Haiku") os="Haiku" ;;
"MINIX") os="MINIX" ;;
"AIX") os="AIX" ;;
"IRIX"*) os="IRIX" ;;
"FreeMiNT") os="FreeMiNT" ;;
*)
printf "%s\n" "Unknown OS detected: '$OSTYPE', aborting..." >&2
printf "%s\n" "Unknown OS detected: '$kernel_name', aborting..." >&2
printf "%s\n" "Open an issue on GitHub to add support for your OS." >&2
exit 1
;;
@@ -1041,7 +1031,7 @@ get_model() {
;;
"iPhone OS")
case "$kernel_machine" in
case "$HOSTTYPE" in
"iPad1,1") model="iPad" ;;
"iPad2,"[1-4]) model="iPad 2" ;;
"iPad3,"[1-3]) model="iPad 3" ;;
@@ -1742,7 +1732,7 @@ get_cpu() {
# Get CPU name.
cpu_file="/proc/cpuinfo"
case "$kernel_machine" in
case "$HOSTTYPE" in
"frv" | "hppa" | "m68k" | "openrisc" | "or"* | "powerpc" | "ppc"* | "sparc"*)
cpu="$(awk -F':' '/^cpu\t|^CPU/ {printf $2; exit}' "$cpu_file")"
;;
@@ -1811,7 +1801,7 @@ get_cpu() {
;;
"iPhone OS")
case "$kernel_machine" in
case "$HOSTTYPE" in
"iPhone1,"[1-2] | "iPod1,1") cpu="Samsung S5L8900 (1) @ 412MHz" ;;
"iPhone2,1") cpu="Samsung S5PC100 (1) @ 600MHz" ;;
"iPhone3,"[1-3] | "iPod4,1") cpu="Apple A4 (1) @ 800MHz" ;;
@@ -2122,7 +2112,7 @@ get_gpu() {
;;
"iPhone OS")
case "$kernel_machine" in
case "$HOSTTYPE" in
"iPhone1,"[1-2]) gpu="PowerVR MBX Lite 3D" ;;
"iPhone5,"[1-4]) gpu="PowerVR SGX543MP3" ;;
"iPhone8,"[1-4]) gpu="PowerVR GT7600" ;;
@@ -3421,8 +3411,17 @@ image_backend() {
}
get_ascii() {
if [[ ! -f "$image_source" ]]; then
err "Ascii: Ascii file not found, using distro ascii."
if [[ ! -f "$image_source" ||
"$image_source" =~ ^(auto|ascii)$ ||
"$image_source" =~ \.(png|jpg|jpe|jpeg|gif)$ ]]; then
# Fallback to distro ascii mode if custom ascii isn't found.
[[ ! "$image_source" =~ ^(auto|ascii)$ ]] && \
err "Ascii: Ascii file not found, using distro ascii."
# Fallback to distro ascii mode if source is an image.
[[ "$image_source" =~ \.(png|jpg|jpe|jpeg|gif)$ ]] && \
err "Image: Source is image file but ascii backend was selected. Using distro ascii."
else
ascii_data="$(< "$image_source")"
fi
@@ -3452,7 +3451,10 @@ get_ascii() {
print="${print//'${c5}'/$c5}"
print="${print//'${c6}'/$c6}"
((text_padding=ascii_length+gap))
# Overwrite padding if ascii_length_force is set.
[[ "$ascii_length_force" ]] && ascii_length="$ascii_length_force"
text_padding="$((ascii_length + gap))"
printf "%b" "$print"
LC_ALL=C
}
@@ -3562,14 +3564,27 @@ END
get_w3m_img_path() {
# Find w3m-img path.
shopt -s nullglob
w3m_paths=({/usr/{local/,},~/.nix-profile/}{lib,libexec,lib64,libexec64}/w3m/w3mi*)
shopt -u nullglob
if [[ -x "/usr/lib/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/lib/w3m/w3mimgdisplay"
[[ -x "${w3m_paths[0]}" ]] && \
{ w3m_img_path="${w3m_paths[0]}"; return; }
elif [[ -x "/usr/libexec/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/libexec/w3m/w3mimgdisplay"
err "Image: w3m-img wasn't found on your system"
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"
elif [[ -x "/usr/local/libexec/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/local/libexec/w3m/w3mimgdisplay"
elif [[ -x "$HOME/.nix-profile/libexec/w3m/w3mimgdisplay" ]]; then
w3m_img_path="$HOME/.nix-profile/libexec/w3m/w3mimgdisplay"
else
err "Image: w3m-img wasn't found on your system"
fi
}
get_term_size() {
@@ -4191,11 +4206,10 @@ dynamic_prompt() {
cache_uname() {
# Cache the output of uname so we don't
# have to spawn it multiple times.
IFS=" " read -ra uname <<< "$(uname -srm)"
IFS=" " read -ra uname <<< "$(uname -sr)"
kernel_name="${uname[0]}"
kernel_version="${uname[1]}"
kernel_machine="${uname[2]}"
}
convert_time() {
@@ -8420,10 +8434,8 @@ main() {
err "Neofetch command: $0 $*"
err "Neofetch version: $version"
# Show error messages.
[[ "$verbose" == "on" ]] && printf "%b" "$err" >&2
# If `--loop` was used, constantly redraw the image.
while [[ "$image_loop" == "on" && "$image_backend" == "w3m" ]]; do display_image; sleep 1; done
return 0