Use memavail when available

This commit is contained in:
Dylan 2016-05-06 18:35:09 +10:00
parent 90925a35ef
commit 1bb9115944
1 changed files with 8 additions and 2 deletions

View File

@ -1212,8 +1212,14 @@ getgpu () {
getmemory () { getmemory () {
case "$os" in case "$os" in
"Linux" | "Windows") "Linux" | "Windows")
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) mem=($(awk -F ':| kB' '/MemTotal|MemFree|Buffers|Cached/ {printf $2}' /proc/meminfo) 0 0)
memused=$((mem[0] - mem[1] - mem[2] - mem[3])) memused=$((mem[0] - mem[1] - mem[2] - mem[3]))
fi
memused=$((memused / 1024)) memused=$((memused / 1024))
memtotal=$((mem[0] / 1024)) memtotal=$((mem[0] / 1024))
;; ;;