diff --git a/neofetch b/neofetch index 9c8ad885..1742f790 100755 --- a/neofetch +++ b/neofetch @@ -44,6 +44,7 @@ get_os() { "MINIX") os="MINIX" ;; "AIX") os="AIX" ;; "IRIX64") os="IRIX" ;; + "HP-UX") os="HP-UX" ;; *) 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 @@ -226,8 +227,11 @@ get_distro() { distro="AIX $(oslevel)" ;; - "IRIX") - distro="IRIX ${kernel_version}" + "IRIX" | "HP-UX") + distro="$os ${kernel_version}" + case "$distro_shorthand" in + "on" | "tiny") distro="${distro/ ${kernel_version}}" ;; + esac ;; esac @@ -339,6 +343,10 @@ get_model() { "AIX") model="$(/usr/bin/uname -M)" ;; + + "HP-UX") + model="$(model)" + ;; esac # Remove dummy OEM info. @@ -368,8 +376,8 @@ get_title() { } get_kernel() { - # Since these OS are integrated systems, it's better to skip this function altogether - [[ "$os" =~ (AIX|IRIX) ]] && return + # Since AIX has no useful output in uname, it's better to skip this function altogether + [[ "$os" == "AIX" ]] && return case "$kernel_shorthand" in "on") kernel="$kernel_version" ;; @@ -377,7 +385,7 @@ get_kernel() { esac # Hide kernel info if it's identical to the distro info. - if [[ "$os" =~ (BSD|MINIX) && "$distro" == *"$kernel_name"* ]]; then + if [[ "$os" =~ (BSD|MINIX|IRIX|HP-UX) && "$distro" == *"$kernel_name"* ]]; then case "$distro_shorthand" in "on" | "tiny") kernel="$kernel_version" ;; *) unset kernel ;; @@ -417,8 +425,8 @@ get_uptime() { seconds="${seconds/.*}" ;; - "AIX" | "IRIX") - t="$(LC_ALL=POSIX ps -o etime= -p 1)" + "AIX" | "IRIX" | "HP-UX") + t="$(LC_ALL=POSIX UNIX95=1 ps -o etime= -p 1)" d="0" h="0" case "$t" in *"-"*) d="${t%%-*}"; t="${t#*-}";; esac case "$t" in *":"*":"*) h="${t%%:*}"; t="${t#*:}";; esac @@ -599,6 +607,10 @@ get_packages() { "IRIX") packages="$(($(versions -b | wc -l)-3))" ;; + + "HP-UX") + packages="$(($(swlist -l product | wc -l)-6))" + ;; esac ((packages == 0)) && unset packages @@ -1070,6 +1082,18 @@ get_cpu() { # Get CPU cores. cores="$(sysconf NPROC_ONLN)" ;; + + "HP-UX") + # Get CPU name. + # This will be partial for now, because apparently hppa and + # IA64 has different approaches of how it should be handled. + + # Get CPU speed. + # Same reasons as above. + + # Get CPU cores. + cores="$(ioscan -k | grep -c "processor")" + ;; esac # Remove un-needed patterns from cpu output. @@ -1405,6 +1429,13 @@ get_memory() { mem_free="$((mem_stat[5] / 1024))" mem_used="$((mem_total - mem_free))" ;; + + "HP-UX") + mem_total="$(machinfo | awk -F':' '/Memory/ {print $2}')" + mem_total="${mem_total/MB*}" + mem_free="$(($(vmstat | awk 'NR==3{printf $5}') / 1024))" + mem_used="$((mem_total - mem_free))" + ;; esac memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB}" @@ -2044,7 +2075,10 @@ get_disk() { # Create an array called 'disks' where each element is a separate line from # df's output. We then unset the first element which removes the column titles. IFS=$'\n' - disks=($(df "${df_flags[@]}" "${disk_show[@]:-/}")) + case "$os" in + "HP-UX") disks=($(bdf "${disk_show[@]:-/}" 2>/dev/null)); df_version="bdf" ;; + *) disks=($(df "${df_flags[@]}" "${disk_show[@]:-/}" 2>/dev/null)) ;; + esac unset 'disks[0]' IFS="$old_ifs" @@ -2060,9 +2094,10 @@ get_disk() { disk_perc="${disk_info[4]/'%'}" case "$df_version" in - *"befhikm"*) - disk="$((disk_info[2]/1024/1024))G / $((disk_info[1]/1024/1024))G (${disk_perc}%)" + *"befhikm"*|"bdf") + disk="$((disk_info[2]/1024/1024))G / $((disk_info[1]/1024/1024)) (${disk_perc}%)" ;; + *) disk="${disk_info[2]/i} / ${disk_info[1]/i} (${disk_perc}%)" ;; esac @@ -2240,6 +2275,7 @@ get_install_date() { esac ;; "AIX") install_file="/var/adm/ras/bosinstlog" ;; + "HP-UX") install_file="/dev/config" ;; esac ls_prog="$(ls --version 2>&1)" @@ -2260,7 +2296,7 @@ get_install_date() { install_date="$(ls -tcd --full-time "$install_file" | awk '{printf $6 " " $7}')" ;; - *"ACFHLNRS"* | *"RadC1xmnlog"*) # AIX ls / IRIX ls + *"ACFHLNRS"* | *"RadC1xmnlog"* | *"1ARadeCx"*) # AIX ls / IRIX ls / HP-UX ls err "Install Date doesn't work because your 'ls' doesn't support full date/time." return ;;