Skip to content

Instantly share code, notes, and snippets.

@ablakely
Created July 8, 2022 06:17
Show Gist options
  • Save ablakely/69b1c2c563209e6790a0feddd6b56e70 to your computer and use it in GitHub Desktop.
Save ablakely/69b1c2c563209e6790a0feddd6b56e70 to your computer and use it in GitHub Desktop.
neofetch patch for OS X 10.4 and 10.5
--- a/neofetch
+++ b/neofetch
@@ -1230,7 +1230,14 @@
if [[ $(kextstat | grep -F -e "FakeSMC" -e "VirtualSMC") != "" ]]; then
model="Hackintosh (SMBIOS: $(sysctl -n hw.model))"
else
- model=$(sysctl -n hw.model)
+ if [[ $osx_version =~ "10.4" || $osx_version =~ "10.5" ]]; then
+ model="$(system_profiler SPHardwareDataType | grep Machine\ Name\:)"
+ model=${model/Machine\ Name\:/}
+
+ model="$model ($(sysctl -n hw.model))"
+ else
+ model=$(sysctl -n hw.model)
+ fi
fi
;;
@@ -2129,7 +2136,20 @@
;;
"Mac OS X"|"macOS")
- cpu="$(sysctl -n machdep.cpu.brand_string)"
+ if [[ $osx_version =~ "10.4" || $osx_version =~ "10.5" ]]; then
+ cpu="$(system_profiler SPHardwareDataType | grep CPU\ Type)"
+ cpu=${cpu/CPU\ Type\:/}
+
+ speed="$(system_profiler SPHardwareDataType | grep CPU\ Speed)"
+ speed=${speed/CPU\ Speed\:/}
+ speed=${speed/ MHz/}
+ speed=${speed/ GHz/}
+
+ cores="$(system_profiler SPHardwareDataType | grep Number\ Of\ CPUs)"
+ cores=${cores/Number\ Of\ CPUs\:/}
+ else
+ cpu="$(sysctl -n machdep.cpu.brand_string)"
+ fi
# Get CPU cores.
case $cpu_cores in
@@ -2559,7 +2579,13 @@
mem_active="$(vm_stat | awk '/ active/ { printf $3 }')"
mem_compressed="$(vm_stat | awk '/ occupied/ { printf $5 }')"
mem_compressed="${mem_compressed:-0}"
- mem_used="$(((${mem_wired//.} + ${mem_active//.} + ${mem_compressed//.}) * 4 / 1024))"
+
+ if [[ $osx_version =~ "10.4" || $osx_version =~ "10.5" ]]; then
+ mem_inactive="$(vm_stat | awk '/ inactive/ { printf $3 }')"
+ mem_used="$(((${mem_inactive//.} + ${mem_active//.}) * 4 / 1024))"
+ else
+ mem_used="$(((${mem_wired//.} + ${mem_active//.} + ${mem_compressed//.}) * 4 / 1024))"
+ fi
;;
"BSD" | "MINIX")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment