From 754d6c6bc9ec930f752247c13df344da85b3fd6c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 3 Nov 2020 05:57:14 +0200 Subject: [PATCH] memory: Support MemAvailable --- pfetch | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 4c0c34b..dc75bea 100755 --- a/pfetch +++ b/pfetch @@ -599,10 +599,26 @@ get_memory() { (MemFree|Buffers|Cached|SReclaimable) mem_used=$((mem_used - val)) ;; + + # If detected this will be used over the above calculation + # for mem_used. Available since Linux 3.14rc. + # See kernel commit 34e431b0ae398fc54ea69ff85ec700722c9da773 + (MemAvailable) + mem_avail=$val + ;; esac done < /proc/meminfo - mem_used=$((mem_used / 1024)) + case $mem_avail in + (*[0-9]*) + mem_used=$(((mem_full - mem_avail) / 1024)) + ;; + + *) + mem_used=$((mem_used / 1024)) + ;; + esac + mem_full=$((mem_full / 1024)) ;;