From c3d60901d92e72086ae03694c0fe33ffffda1422 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sun, 18 Dec 2016 21:34:29 +0700 Subject: [PATCH 1/8] 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 From ffc1991628505b572423b824bbe7381672ac6f3d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 19 Dec 2016 11:38:06 +1100 Subject: [PATCH 2/8] Ascii: Added ascii for Minix --- ascii/distro/minix | 17 +++++++++++++++++ neofetch | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 ascii/distro/minix diff --git a/ascii/distro/minix b/ascii/distro/minix new file mode 100644 index 00000000..a0ff143c --- /dev/null +++ b/ascii/distro/minix @@ -0,0 +1,17 @@ +${c2} -sdhyo+:-` -/syymm: + sdyooymmNNy. `` .smNmmdysNd + odyoso+syNNmysoyhhdhsoomNmm+/osdm/ + :hhy+-/syNNmddhddddddmNMNo:sdNd: + `smNNdNmmNmddddddddddmmmmmmmy` + `ohhhhdddddmmNNdmddNmNNmdddddmdh- + odNNNmdyo/:/-/hNddNy-`..-+ydNNNmd: + `+mNho:` smmd/ sNNh :dmms` -+ymmo. +-od/ -m${c1}mm${c2}mo -NN+ +m${c1}mm${c2}m- yms: ++sms -.` :so: .NN+ :os/ .-`mNh: +.-hyh+:////- -sNNd:` .--://ohNs- + `:hNNNNNNNMMd/sNMmhsdMMh/ymmNNNmmNNy/ + -+sNNNNMMNNNsmNMo: :NNmymNNNNMMMms: + //oydNMMMMydMMNysNMMmsMMMMMNyo/` + ../-yNMMy--/::/-.sMMmos+.` + -+oyhNsooo+omy/``` + `::ohdmds-` diff --git a/neofetch b/neofetch index 48796521..1da53997 100755 --- a/neofetch +++ b/neofetch @@ -2445,7 +2445,7 @@ get_distro_colors() { set_colors 2 1 ;; - "Debian"* | "Ubuntu"* | "DragonFly"* | "PacBSD"* | "Oracle"* | "BlankOn"* | "DracOS"* | "Peppermint"*) + "Debian"* | "Ubuntu"* | "DragonFly"* | "PacBSD"* | "Oracle"* | "BlankOn"* | "DracOS"* | "Peppermint"* | "Minix"*) set_colors 1 7 3 ;; From 6339b2f27a3c9feddbc88fcd8b1099fff3068a1f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 19 Dec 2016 11:54:52 +1100 Subject: [PATCH 3/8] OS: Add inital support for Minix (Konimex) --- ascii/distro/minix | 17 +++++++++++++++++ neofetch | 38 ++++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 ascii/distro/minix diff --git a/ascii/distro/minix b/ascii/distro/minix new file mode 100644 index 00000000..a0ff143c --- /dev/null +++ b/ascii/distro/minix @@ -0,0 +1,17 @@ +${c2} -sdhyo+:-` -/syymm: + sdyooymmNNy. `` .smNmmdysNd + odyoso+syNNmysoyhhdhsoomNmm+/osdm/ + :hhy+-/syNNmddhddddddmNMNo:sdNd: + `smNNdNmmNmddddddddddmmmmmmmy` + `ohhhhdddddmmNNdmddNmNNmdddddmdh- + odNNNmdyo/:/-/hNddNy-`..-+ydNNNmd: + `+mNho:` smmd/ sNNh :dmms` -+ymmo. +-od/ -m${c1}mm${c2}mo -NN+ +m${c1}mm${c2}m- yms: ++sms -.` :so: .NN+ :os/ .-`mNh: +.-hyh+:////- -sNNd:` .--://ohNs- + `:hNNNNNNNMMd/sNMmhsdMMh/ymmNNNmmNNy/ + -+sNNNNMMNNNsmNMo: :NNmymNNNNMMMms: + //oydNMMMMydMMNysNMMmsMMMMMNyo/` + ../-yNMMy--/::/-.sMMmos+.` + -+oyhNsooo+omy/``` + `::ohdmds-` diff --git a/neofetch b/neofetch index 9892543c..186b9221 100755 --- a/neofetch +++ b/neofetch @@ -37,6 +37,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 } @@ -145,7 +146,7 @@ get_distro() { os_arch="off" ;; - "BSD") + "BSD" | "MINIX") case "$distro_shorthand" in "tiny" | "on") distro="$kernel_name" ;; *) distro="$kernel_name $kernel_version" ;; @@ -249,7 +250,7 @@ get_model() { esac ;; - "BSD") + "BSD" | "MINIX") model="$(sysctl -n hw.vendor hw.product)" ;; @@ -283,6 +284,8 @@ get_title() { } get_kernel() { + [[ "$os" == "MINIX" ]] && local os="BSD" + case "$kernel_shorthand" in "on") kernel="$kernel_version" ;; "off") kernel="$kernel_name $kernel_version" ;; @@ -309,7 +312,7 @@ get_uptime() { *) # Get uptime in seconds case "$os" in - "Linux" | "Windows") + "Linux" | "Windows" | "MINIX") seconds="$(< /proc/uptime)" seconds="${seconds/.*}" ;; @@ -448,7 +451,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))" @@ -720,7 +723,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") @@ -936,7 +939,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")" ;; @@ -1038,7 +1041,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")" @@ -1095,7 +1098,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))" ;; @@ -1109,7 +1112,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 @@ -1226,7 +1232,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, "}')" ;; @@ -1484,7 +1490,7 @@ get_term() { case "${name// }" in "${SHELL/*\/}" | *"sh" | "tmux"* | "screen" | "su") get_term "$parent" ;; - "login"* | *"Login"* | "init") term="$(tty)" ;; + "login"* | *"Login"* | "init" | "(init)") term="$(tty)" ;; "ruby" | "1" | "systemd" | "sshd"* | "python"* | "USER"*"PID"*) unset term ;; "gnome-terminal-") term="gnome-terminal" ;; *) term="${name##*/}" ;; @@ -1645,7 +1651,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}')" ;; @@ -1697,9 +1703,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="/" ;; @@ -1934,7 +1940,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 @@ -2447,7 +2453,7 @@ get_distro_colors() { set_colors 2 1 ;; - "Debian"* | "Ubuntu"* | "DragonFly"* | "PacBSD"* | "Oracle"* | "BlankOn"* | "DracOS"* | "Peppermint"*) + "Debian"* | "Ubuntu"* | "DragonFly"* | "PacBSD"* | "Oracle"* | "BlankOn"* | "DracOS"* | "Peppermint"* | "Minix"*) set_colors 1 7 3 ;; From 446926ddb46248718448c6d30b56ab28efbd5832 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 19 Dec 2016 11:56:16 +1100 Subject: [PATCH 4/8] Shell: Fix bug with sh and --version --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index 186b9221..c4959c61 100755 --- a/neofetch +++ b/neofetch @@ -505,6 +505,7 @@ get_shell() { if [[ "$shell_version" == "on" ]]; then case "${SHELL##*/}" in "bash") shell+="${BASH_VERSION/-*}" ;; + "sh") ;; "mksh" | "ksh") shell+="$("$SHELL" -c 'printf "%s" "$KSH_VERSION"')" From d396c14f2a1015b56adc38d0c60020d3d81660dc Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 19 Dec 2016 11:58:49 +1100 Subject: [PATCH 5/8] Local IP: Fix IP address on Minix --- neofetch | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index c4959c61..df8e007c 100755 --- a/neofetch +++ b/neofetch @@ -1652,11 +1652,15 @@ get_battery() { get_local_ip() { case "$os" in - "Linux" | "BSD" | "Solaris" | "MINIX") + "Linux" | "BSD" | "Solaris") local_ip="$(ip route get 1 | awk '{print $NF;exit}')" [[ -z "$local_ip" ]] && local_ip="$(ifconfig | awk '/broadcast/ {print $2}')" ;; + "MINIX") + local_ip="$(ifconfig | awk '{printf $3; exit}')" + ;; + "Mac OS X" | "iPhone OS") local_ip="$(ipconfig getifaddr en0)" [[ -z "$local_ip" ]] && local_ip="$(ipconfig getifaddr en1)" From 2942abd46bb5637e59e7c3a8522b59cac361aa84 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 19 Dec 2016 12:07:20 +1100 Subject: [PATCH 6/8] Disk: Fix disk on Minix --- neofetch | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index df8e007c..0295a29b 100755 --- a/neofetch +++ b/neofetch @@ -1552,10 +1552,16 @@ get_term_font() { get_disk() { type -p df >/dev/null 2>&1 || { err "Disk requires 'df' to function. Install 'df' to get disk info."; return; } - [[ "$os" == "Haiku" ]] && { err "Disk doesn't work on Haiku due to the non-standard 'df'"; return; } + + # Get 'df' flags. + case "$os" in + "Haiku") err "Disk doesn't work on Haiku due to the non-standard 'df'"; return ;; + "Minix") df_flags=(-P -h) ;; + *) df_flags=(-h) ;; + esac # Get the info for / - disks=($(df -P -h /)) || { err "Disk: 'df' exited with error code 1"; return; } + disks=($(df "${df_flags[@]}" /)) || { err "Disk: 'df' exited with error code 1"; return; } # Put it all together disk_perc="${disks[11]/'%'}" From b3932af5016a2e7bb0d9e906f6569fcda73048c3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 19 Dec 2016 12:08:35 +1100 Subject: [PATCH 7/8] Disk: Fix flags on Minix 2 --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 0295a29b..dd7de0f0 100755 --- a/neofetch +++ b/neofetch @@ -1556,8 +1556,8 @@ get_disk() { # Get 'df' flags. case "$os" in "Haiku") err "Disk doesn't work on Haiku due to the non-standard 'df'"; return ;; - "Minix") df_flags=(-P -h) ;; - *) df_flags=(-h) ;; + "Minix") df_flags=(-h) ;; + *) df_flags=(-P -h) ;; esac # Get the info for / From 6e7dfef790fd99ce49c4c0fe0560f94595bce0fe Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Mon, 19 Dec 2016 10:42:50 +0700 Subject: [PATCH 8/8] Local IP [Minix]: Deleted case in Linux/BSD/Solaris' local_ip --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 8982916f..dd7de0f0 100755 --- a/neofetch +++ b/neofetch @@ -1658,7 +1658,7 @@ get_battery() { get_local_ip() { case "$os" in - "Linux" | "BSD" | "Solaris" | "MINIX") + "Linux" | "BSD" | "Solaris") local_ip="$(ip route get 1 | awk '{print $NF;exit}')" [[ -z "$local_ip" ]] && local_ip="$(ifconfig | awk '/broadcast/ {print $2}')" ;;