From c3d60901d92e72086ae03694c0fe33ffffda1422 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sun, 18 Dec 2016 21:34:29 +0700 Subject: [PATCH] OS: Added initial support for MINIX --- neofetch | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/neofetch b/neofetch index b60a978a..48796521 100755 --- a/neofetch +++ b/neofetch @@ -38,6 +38,7 @@ get_os() { "CYGWIN"*) os="Windows" ;; "SunOS") os="Solaris" ;; "Haiku") os="Haiku" ;; + "MINIX") os="MINIX" ;; *) printf "%s\n" "Unknown OS detected: $kernel_name"; exit 1 ;; esac } @@ -146,7 +147,7 @@ get_distro() { os_arch="off" ;; - "BSD") + "BSD" | "MINIX") case "$distro_shorthand" in "tiny" | "on") distro="$kernel_name" ;; *) distro="$kernel_name $kernel_version" ;; @@ -250,7 +251,7 @@ get_model() { esac ;; - "BSD") + "BSD" | "MINIX") model="$(sysctl -n hw.vendor hw.product)" ;; @@ -284,6 +285,8 @@ get_title() { } get_kernel() { + [[ "$os" == "MINIX" ]] && local os="BSD" + case "$kernel_shorthand" in "on") kernel="$kernel_version" ;; "off") kernel="$kernel_name $kernel_version" ;; @@ -310,7 +313,7 @@ get_uptime() { *) # Get uptime in seconds case "$os" in - "Linux" | "Windows") + "Linux" | "Windows" | "MINIX") seconds="$(< /proc/uptime)" seconds="${seconds/.*}" ;; @@ -441,7 +444,7 @@ get_packages() { fi ;; - "Mac OS X") + "Mac OS X" | "MINIX") [[ -d "/usr/local/bin" ]] && \ packages="$(($(ls -l /usr/local/bin/ | grep -cv "\(../Cellar/\|brew\)") - 1))" @@ -713,7 +716,7 @@ get_cpu() { # NetBSD emulates the linux /proc filesystem instead of using sysctl for hw # information so we have to use this block below which temporarily sets the # OS to 'Linux' for the duration of this function. - [[ "$distro" == "NetBSD"* ]] && local os="Linux" + [[ "$distro" == "NetBSD"* || "$os" == "MINIX" ]] && local os="Linux" case "$os" in "Linux" | "Windows") @@ -929,7 +932,7 @@ get_cpu_usage() { # Get cores if unset if [[ "$cpu_cores" == "off" ]]; then case "$os" in - "Linux") cores="$(grep -c "^processor" /proc/cpuinfo)" ;; + "Linux" | "MINIX") cores="$(grep -c "^processor" /proc/cpuinfo)" ;; "Mac OS X") cores="$(sysctl -n hw.logicalcpu_max)" ;; "BSD") cores="$(sysctl -n hw.ncpu)" ;; "Solaris") cores="$(kstat -m cpu_info | grep -c -F "chip_id")" ;; @@ -1031,7 +1034,7 @@ get_gpu() { esac ;; - "BSD" | "Solaris") + "BSD" | "Solaris" | "MINIX") case "$kernel_name" in "FreeBSD"* | "DragonFly"*) gpu="$(pciconf -lv | grep -B 4 -F "VGA" | grep -F "device")" @@ -1088,7 +1091,7 @@ get_memory() { mem_used="$(((${mem_wired//.} + ${mem_active//.} + ${mem_compressed//.}) * 4 / 1024))" ;; - "BSD") + "BSD" | "MINIX") # Mem total case "$kernel_name" in "NetBSD"*) mem_total="$(($(sysctl -n hw.physmem64) / 1024 / 1024))" ;; @@ -1102,7 +1105,10 @@ get_memory() { mem_free="$(top -d 1 | awk -F ',' '/^Mem:/ {print $5}')" mem_free="${mem_free/M Free}" ;; - + "MINIX") + mem_free="$(top -d 1 | awk -F ',' '/^Memory:/ {print $2}')" + mem_free="${mem_free/M Free}" + ;; "OpenBSD"*) ;; *) mem_free="$(($(vmstat | awk 'END{printf $5}') / 1024))" ;; esac @@ -1218,7 +1224,7 @@ get_song() { get_resolution() { case "$os" in - "Linux" | "BSD" | "Solaris") + "Linux" | "BSD" | "Solaris" | "MINIX") if type -p xrandr >/dev/null; then case "$refresh_rate" in "on") resolution="$(xrandr --nograb --current | awk 'match($0,/[0-9]*\.[0-9]*\*/) {printf $1 " @ " substr($0,RSTART,RLENGTH) "Hz, "}')" ;; @@ -1637,7 +1643,7 @@ get_battery() { get_local_ip() { case "$os" in - "Linux" | "BSD" | "Solaris") + "Linux" | "BSD" | "Solaris" | "MINIX") local_ip="$(ip route get 1 | awk '{print $NF;exit}')" [[ -z "$local_ip" ]] && local_ip="$(ifconfig | awk '/broadcast/ {print $2}')" ;; @@ -1689,9 +1695,9 @@ get_install_date() { install_date="$(ls -lUT /var/log/install.log | awk '{printf $9 " " $6 " " $7 " " $8}')" ;; - "BSD") + "BSD" | "MINIX") case "$kernel_name" in - "OpenBSD"* | "Bitrig"*) + "OpenBSD"* | "Bitrig"* | "MINIX") install_file="/" ;; @@ -1926,7 +1932,7 @@ get_w3m_img_path() { get_wallpaper() { case "$os" in - "Linux" | "BSD" | "Solaris") + "Linux" | "BSD" | "Solaris" | "MINIX") # Get DE if user has disabled the function. (( "$de_run" != 1 )) && get_de