memory: Support MemAvailable

This commit is contained in:
Dylan Araps 2020-11-03 05:57:14 +02:00
parent a4f9cb96e9
commit 754d6c6bc9
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

18
pfetch
View File

@ -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))
;;