neofetch: Use MemAvailable for memory on Linux if supported. Closes #1591
This commit is contained in:
parent
4660ae7a53
commit
106a53c575
11
neofetch
11
neofetch
|
@ -2568,10 +2568,21 @@ get_memory() {
|
||||||
"MemFree" | "Buffers" | "Cached" | "SReclaimable")
|
"MemFree" | "Buffers" | "Cached" | "SReclaimable")
|
||||||
mem_used="$((mem_used-=${b/kB}))"
|
mem_used="$((mem_used-=${b/kB}))"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
# Available since Linux 3.14rc (34e431b0ae398fc54ea69ff85ec700722c9da773).
|
||||||
|
# If detected this will be used over the above calculation for mem_used.
|
||||||
|
"MemAvailable")
|
||||||
|
mem_avail=${b/kB}
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done < /proc/meminfo
|
done < /proc/meminfo
|
||||||
|
|
||||||
|
if [[ $mem_avail ]]; then
|
||||||
|
mem_used=$(((mem_total - mem_avail) / 1024))
|
||||||
|
else
|
||||||
mem_used="$((mem_used / 1024))"
|
mem_used="$((mem_used / 1024))"
|
||||||
|
fi
|
||||||
|
|
||||||
mem_total="$((mem_total / 1024))"
|
mem_total="$((mem_total / 1024))"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Reference in New Issue