Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Rework macOS memory calculation to work on Apple Silicon
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Wallisch committed May 19, 2021
1 parent 6dd85d6 commit 4651682
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions neofetch
Original file line number Diff line number Diff line change
Expand Up @@ -2601,12 +2601,15 @@ get_memory() {
;;

"Mac OS X" | "macOS" | "iPhone OS")
hw_pagesize="$(sysctl -n hw.pagesize)"
mem_total="$(($(sysctl -n hw.memsize) / 1024 / 1024))"
mem_wired="$(vm_stat | awk '/ wired/ { print $4 }')"
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))"
pages_pageable="$(sysctl -n vm.page_pageable_internal_count)"
pages_purgeable="$(vm_stat | awk '/ purgeable/ { printf $3 }')"
pages_app="$((${pages_pageable} - ${pages_purgeable//.}))"
pages_wired="$(vm_stat | awk '/ wired/ { print $4 }')"
pages_compressed="$(vm_stat | awk '/ occupied/ { printf $5 }')"
pages_compressed="${pages_compressed:-0}"
mem_used="$(((${pages_app} + ${pages_wired//.} + ${pages_compressed//.}) * hw_pagesize / 1024 / 1024))"
;;

"BSD" | "MINIX")
Expand Down

0 comments on commit 4651682

Please sign in to comment.