From b744122e0dc69fb618f8afae8e6f66337102990f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 25 Sep 2019 10:48:38 +0300 Subject: [PATCH] netbsd: memory detection --- pfetch | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pfetch b/pfetch index 92f0fa2..1809875 100755 --- a/pfetch +++ b/pfetch @@ -394,6 +394,23 @@ get_memory() { # the used memory amount, I'll be able to add support here. mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) ;; + + NetBSD*) + mem_full=$(($(sysctl -n hw.physmem64) / 1024 / 1024)) + + # NetBSD implements a lot of the Linux '/proc' filesystem, + # this uses the same parser as the Linux memory detection. + while IFS=:k read -r key val _; do + case $key in + MemFree) + mem_free=$((val / 1024)) + break + ;; + esac + done < /proc/meminfo + + mem_used=$((mem_full - mem_free)) + ;; esac log memory "${mem_used:-?}MiB / ${mem_full:-?}MiB" >&6