From 1bb911594485d9991e7db1634fde3086f3a7750b Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 6 May 2016 18:35:09 +1000 Subject: [PATCH] Use memavail when available --- neofetch | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 8c2463f7..f7a46e41 100755 --- a/neofetch +++ b/neofetch @@ -1212,8 +1212,14 @@ getgpu () { getmemory () { case "$os" in "Linux" | "Windows") - mem=($(awk -F ':| kB' '/MemTotal|MemFree|Buffers|Cached/ {printf $2}' /proc/meminfo) 0 0) - memused=$((mem[0] - mem[1] - mem[2] - mem[3])) + if [ ! -z "$(grep -F "MemAvail" /proc/meminfo)" ]; then + mem=($(awk -F ':| kB' '/MemTotal|MemAvail/ {printf $2}' /proc/meminfo)) + memused=$((mem[0] - mem[1])) + else + mem=($(awk -F ':| kB' '/MemTotal|MemFree|Buffers|Cached/ {printf $2}' /proc/meminfo) 0 0) + memused=$((mem[0] - mem[1] - mem[2] - mem[3])) + fi + memused=$((memused / 1024)) memtotal=$((mem[0] / 1024)) ;;