From 987c67fdd523fce46ef4fbd452ba24a99ee26115 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 13 May 2016 09:57:40 +1000 Subject: [PATCH] Fix memory usage for all BSD distros we support --- neofetch | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 2abe24d8..1191a2a5 100755 --- a/neofetch +++ b/neofetch @@ -1409,7 +1409,21 @@ getmemory () { ;; "BSD") - memtotal=$(($(sysctl -n hw.physmem) / 1000)) + case "$distro" in + "OpenBSD"*) + memtotal=$(top -d 1 | awk -F ': |/| |M' '/Memory:/ {printf $4}') + ;; + + "FreeBSD"* | "DragonFly"*) + memtotal=$(dmesg | awk -F '\\(| ' '/real mem/ {printf $7}') + ;; + + "NetBSD"*) + memtotal=$(awk -F ':|kB' '/MemTotal:/ {printf $2}' /proc/meminfo) + memtotal=$((memtotal / 1024)) + ;; + esac + memfree=$(($(vmstat | awk 'END{printf $4}') / 1000)) memused=$((memtotal - ${memfree/M})) ;;