From 04ba1d2c3bb2d9cf56caac553bca609559805929 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 18 Jan 2016 17:45:32 +1100 Subject: [PATCH] Fix memory usage on BSD --- fetch | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/fetch b/fetch index 21df78cc..0ad28cc9 100755 --- a/fetch +++ b/fetch @@ -641,25 +641,23 @@ getmemory () { memory="${memused}MB / ${memtotal}MB" ;; - "FreeBSD") - memtotal=$(dmesg | awk '/real mem/ {printf $5}') - memtotal=${memtotal/\(/} - memtotal=${memtotal/)MB/} - memfree=$(top -d 1 | awk '/Mem:/ {printf $10}') - memfree=${memfree/M/} - memused=$((memtotal - memfree)) - - memory="${memused}MB / ${memtotal}MB" - ;; - - *"BSD") + "BSD") memtotal=$(dmesg | awk '/real mem/ {printf $5}') memtotal=${memtotal/\(/} memtotal=${memtotal/MB\)/} - memfree=$(top -d 1 | awk '/Real:/ {print $6}') + + case "$distro" in + "FreeBSD") + memfree=$(top -d 1 | awk '/Mem:/ {printf $10}') + ;; + + *) + memfree=$(top -d 1 | awk '/Real:/ {print $6}') + ;; + esac + memfree=${memfree/M/} memused=$((memtotal - memfree)) - memory="${memused}MB / ${memtotal}MB" ;;