From 96762bd61c4ef4dc3ca71891f1fdb6b137f3432e Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Tue, 2 Jan 2024 20:26:08 -0500 Subject: [PATCH 01/10] Initial z/OS support --- neofetch | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 48b96d215..dff4f5d56 100755 --- a/neofetch +++ b/neofetch @@ -1,4 +1,4 @@ -#!/usr/bin/env bash + #!/usr/bin/env bash # vim: noai:ts=4:sw=4:expandtab # shellcheck source=/dev/null # shellcheck disable=2009 @@ -958,6 +958,10 @@ get_os() { os=Windows ;; + "z/OS") + os="z/OS" + ;; + *) 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 @@ -1210,6 +1214,11 @@ get_distro() { FreeMiNT) distro=FreeMiNT ;; + + "z/OS") + distro="IBM z/OS ${kernel_version}" + os_arch=off + ;; esac distro=${distro//Enterprise Server} @@ -1356,6 +1365,32 @@ get_model() { model=$(sysctl -n hw.model) model=${model/ (_MCH *)} ;; + + "z/OS") + case $kernel_machine in + 2064): "IBM z900 (Freeway)" ;; + 2066): "IBM z800 (Raptor)" ;; + 2084): "IBM z990 (T-Rex)" ;; + 2086): "IBM z890 (pTero)" ;; + 2094): "IBM z9 EC (Danu)" ;; + 2096): "IBM z9 BC (Pollux)" ;; + 2097): "IBM z10 EC (eCLipz)" ;; + 2098): "IBM z10 BC (eCLipz)" ;; + 2817): "IBM z196 (Gryphon)" ;; + 2818): "IBM z114 (Gryphon)" ;; + 2827): "IBM zEC12 (Helix)" ;; + 2828): "IBM zBC12 (Helix)" ;; + 2964): "IBM z13 (Sphinx)" ;; + 2965): "IBM z13s (Sphinx)" ;; + 3906): "IBM z14 (Midas)" ;; + 3907): "IBM z14 Model ZR1 (Zeus)" ;; + 8561): "IBM z15 (Themis)" ;; + 8562): "IBM z15 Model T02 (Athena)" ;; + 3931): "IBM z16 (Artemis)" ;; + 3932): "IBM z16 Model A02 (Selene)" ;; + esac + + model=$_ esac # Remove dummy OEM info. @@ -1419,6 +1454,11 @@ get_kernel() { on|tiny) kernel=$kernel_version ;; *) unset kernel ;; esac + + # z/OS doesn't have a separate kernel version. + [[ $os == "z/OS" ]] && { + unset kernel + } } get_uptime() { @@ -4910,6 +4950,19 @@ cache_uname() { esac } fi + + if [[ "$kernel_name" == "OS/390" ]]; then + # z/OS has a non-standard -I argument for uname. + IFS=" " read -ra uname <<< "$(uname -srmvI)" + + kernel_name="${uname[0]}" + kernel_machine="${uname[3]}" + kv="$((10#${uname[2]}))" + kr="$((10#${uname[1]:0:2}))" + + kernel_version="$kv.$kr" + + fi } get_ppid() { From 76431d5237d3b67a90c19bf0dfd5ce6ad04fa7a2 Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Tue, 2 Jan 2024 20:38:04 -0500 Subject: [PATCH 02/10] Simplify kernel version code --- neofetch | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) mode change 100755 => 100644 neofetch diff --git a/neofetch b/neofetch old mode 100755 new mode 100644 index dff4f5d56..7f09ace48 --- a/neofetch +++ b/neofetch @@ -1,4 +1,4 @@ - #!/usr/bin/env bash + #!/usr/bin/env bash # vim: noai:ts=4:sw=4:expandtab # shellcheck source=/dev/null # shellcheck disable=2009 @@ -4956,12 +4956,8 @@ cache_uname() { IFS=" " read -ra uname <<< "$(uname -srmvI)" kernel_name="${uname[0]}" + kernel_version="$((10#${uname[2]})).$((10#${uname[1]:0:2}))" kernel_machine="${uname[3]}" - kv="$((10#${uname[2]}))" - kr="$((10#${uname[1]:0:2}))" - - kernel_version="$kv.$kr" - fi } From 86124577cbe667076f9216330f81667d38db584a Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Tue, 2 Jan 2024 22:51:41 -0500 Subject: [PATCH 03/10] Add uptime support --- neofetch | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 neofetch diff --git a/neofetch b/neofetch old mode 100644 new mode 100755 index 7f09ace48..a1c874101 --- a/neofetch +++ b/neofetch @@ -1,4 +1,4 @@ - #!/usr/bin/env bash +#!/usr/bin/env bash # vim: noai:ts=4:sw=4:expandtab # shellcheck source=/dev/null # shellcheck disable=2009 @@ -1505,6 +1505,14 @@ get_uptime() { Haiku) s=$(($(system_time) / 1000000)) ;; + + z/OS) + IFS=" " read -ra ut <<< "$(uptime)" + df="$((10#${ut[2]}))" + hf="$((10#${ut[4]:0:2}))" + mf="$((10#${ut[4]:3:2}))" + s="$((df * 60 * 60 * 24 + hf * 60 * 60 + mf * 60))" + ;; esac d="$((s / 60 / 60 / 24)) days" From a48b44e89e9256671c71fe94384f4a157b567af5 Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Tue, 2 Jan 2024 22:52:43 -0500 Subject: [PATCH 04/10] Add comment --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index a1c874101..30056dcd6 100755 --- a/neofetch +++ b/neofetch @@ -1507,6 +1507,7 @@ get_uptime() { ;; z/OS) + # z/OS doesn't have /proc until v3.1. IFS=" " read -ra ut <<< "$(uptime)" df="$((10#${ut[2]}))" hf="$((10#${ut[4]:0:2}))" From c5e2c082c9f140aa553b02ae0bdaea521d725e40 Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Wed, 3 Jan 2024 10:57:17 -0500 Subject: [PATCH 05/10] Add initial EBCDIC art --- neofetch | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 30056dcd6..ad99dd028 100755 --- a/neofetch +++ b/neofetch @@ -1216,7 +1216,7 @@ get_distro() { ;; "z/OS") - distro="IBM z/OS ${kernel_version}" + distro="z/OS ${kernel_version}" os_arch=off ;; esac @@ -11426,6 +11426,21 @@ ssssssssssssso/-` `-/osssssssssssss .+oooooooooooooooooooooooo+. -osssssssssssssssssssssso- `osssssssssssssssssssso` +EOF + ;; + + "z/OS"*) + set_colors 12 + read -rd '' ascii_data <<'EOF' +${c1} // OOO SSSS + // OO OO SS SS +zzzzzz // OO OO SSS +z zz // OO OO SSS + zz // OO OO SSS + zz z // OO OO SS SS +zzzzzz / OOO SSSS + + EOF ;; From c00b00fee20952c57f3d521ca07be8867b14409b Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Wed, 3 Jan 2024 16:49:35 -0500 Subject: [PATCH 06/10] Add CPU count --- neofetch | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/neofetch b/neofetch index ad99dd028..08d352b0e 100755 --- a/neofetch +++ b/neofetch @@ -2480,6 +2480,17 @@ get_cpu() { cpu="$(awk -F':' '/CPU:/ {printf $2}' /kern/cpuinfo)" speed="$(awk -F '[:.M]' '/Clocking:/ {printf $2}' /kern/cpuinfo)" ;; + + "z/OS") + cpu="IBM Z CPU" + + # Create a temporary REXX exec to get the number of CPUs in the system. + REXXFILE="/tmp/cpus.rexx" + printf "/* REXX */\nx = SYSCPUS('CPUS.')\nsay CPUS.0\n" > ${REXXFILE} + chmod +x ${REXXFILE} + cores=$($REXXFILE) + rm -f ${REXXFILE} + ;; esac # Remove un-needed patterns from cpu output. From f6eaca078a0e07632c3b09a9e9f5a183ee1ded65 Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Thu, 4 Jan 2024 11:24:04 -0500 Subject: [PATCH 07/10] Get total system memory --- neofetch | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 08d352b0e..5d844bc52 100755 --- a/neofetch +++ b/neofetch @@ -2485,7 +2485,7 @@ get_cpu() { cpu="IBM Z CPU" # Create a temporary REXX exec to get the number of CPUs in the system. - REXXFILE="/tmp/cpus.rexx" + REXXFILE="/tmp/cpus-$$.rexx" printf "/* REXX */\nx = SYSCPUS('CPUS.')\nsay CPUS.0\n" > ${REXXFILE} chmod +x ${REXXFILE} cores=$($REXXFILE) @@ -2763,6 +2763,16 @@ get_memory() { mem_total="$((mem_total / 1024))" ;; + "z/OS") + memory_unit="gib" + # Create a temporary REXX exec to get the number of CPUs in the system. + REXXFILE="/tmp/memory-$$.rexx" + printf "/* REXX */\nNumeric digits 20\nsay C2d(Storage(D2x(C2d(Storage(10,4)) + 856),4))/1024\n" > ${REXXFILE} + chmod +x ${REXXFILE} + mem_total=$($REXXFILE) + rm -f ${REXXFILE} + ;; + "Mac OS X" | "macOS" | "iPhone OS") hw_pagesize="$(sysctl -n hw.pagesize)" mem_total="$(($(sysctl -n hw.memsize) / 1024 / 1024))" From 49682460ae7124b1ca4fa81f1af87b51f962e629 Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Thu, 4 Jan 2024 13:29:55 -0500 Subject: [PATCH 08/10] Support mem_used --- neofetch | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 5d844bc52..59bb2c926 100755 --- a/neofetch +++ b/neofetch @@ -2765,12 +2765,15 @@ get_memory() { "z/OS") memory_unit="gib" - # Create a temporary REXX exec to get the number of CPUs in the system. + # Create a temporary REXX exec to get amount of memory in the system. REXXFILE="/tmp/memory-$$.rexx" printf "/* REXX */\nNumeric digits 20\nsay C2d(Storage(D2x(C2d(Storage(10,4)) + 856),4))/1024\n" > ${REXXFILE} chmod +x ${REXXFILE} mem_total=$($REXXFILE) + printf "/* REXX */\nNumeric digits 20\nsay C2d(Storage(D2x(C2d(Storage(D2x(C2d(Storage(10,4)) + 1168),4)) + 136),4)) * 4096 // (1024*1024)\n" > ${REXXFILE} + mem_avail=$($REXXFILE) rm -f ${REXXFILE} + mem_used=$((mem_total - mem_avail)) ;; "Mac OS X" | "macOS" | "iPhone OS") From 005042516ed5be5d09aabfa5e2ede9aa50f123f5 Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Fri, 5 Jan 2024 10:42:30 -0500 Subject: [PATCH 09/10] Combine REXX invocations --- neofetch | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index 59bb2c926..b4320e51b 100755 --- a/neofetch +++ b/neofetch @@ -2765,15 +2765,25 @@ get_memory() { "z/OS") memory_unit="gib" - # Create a temporary REXX exec to get amount of memory in the system. + # Create a temporary REXX exec to get the amount of memory in the system. + read -rd '' rexx_code <<'EOF' +/* REXX */ +Numeric digits 20 +TOTALMEM = C2d(Storage(D2x(C2d(Storage(10,4)) + 856),4))/1024 +CVT = C2d(Storage(10,4)) +CVTRCEP = C2d(Storage(D2x(CVT + 1168),4)) +FREEMEM = trunc(C2d(Storage(D2x(CVTRCEP + 136),4)) * 4096 / (1024 * 1024)) + +say TOTALMEM FREEMEM +EOF REXXFILE="/tmp/memory-$$.rexx" - printf "/* REXX */\nNumeric digits 20\nsay C2d(Storage(D2x(C2d(Storage(10,4)) + 856),4))/1024\n" > ${REXXFILE} + printf "%s\n" "${rexx_code}" > ${REXXFILE} chmod +x ${REXXFILE} - mem_total=$($REXXFILE) - printf "/* REXX */\nNumeric digits 20\nsay C2d(Storage(D2x(C2d(Storage(D2x(C2d(Storage(10,4)) + 1168),4)) + 136),4)) * 4096 // (1024*1024)\n" > ${REXXFILE} - mem_avail=$($REXXFILE) - rm -f ${REXXFILE} + IFS=" " read -ra rexx_data <<< "$($REXXFILE)" + mem_total="${rexx_data[0]}" + mem_avail="${rexx_data[1]}" mem_used=$((mem_total - mem_avail)) + rm -f ${REXXFILE} ;; "Mac OS X" | "macOS" | "iPhone OS") From 38c36ac6898e390641592b15bed30efe8aa2b83b Mon Sep 17 00:00:00 2001 From: Anthony Giorgio Date: Fri, 5 Jan 2024 11:18:58 -0500 Subject: [PATCH 10/10] Adjust z/OS logo --- neofetch | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index b4320e51b..e5739f05d 100755 --- a/neofetch +++ b/neofetch @@ -11466,15 +11466,13 @@ EOF "z/OS"*) set_colors 12 read -rd '' ascii_data <<'EOF' -${c1} // OOO SSSS - // OO OO SS SS -zzzzzz // OO OO SSS -z zz // OO OO SSS - zz // OO OO SSS - zz z // OO OO SS SS -zzzzzz / OOO SSSS - - +${c1} // OOOOOOO SSSSSSS + // OO OO SS + zzzzzz // OO OO SS + zz // OO OO SSSS + zz // OO OO SS + zz // OO OO SS +zzzzzz // OOOOOOO SSSSSSS EOF ;;