Merge pull request #175 from dylanaraps/memory_legacy

Rewrite memory function to work on older linux kernel versions.
This commit is contained in:
Dylan Araps 2016-03-26 22:31:25 +11:00
commit 9b5cf28793

View file

@ -1114,17 +1114,9 @@ getgpu () {
getmemory () { getmemory () {
case "$os" in case "$os" in
"Linux") "Linux")
# Read first 3 lines mem=($(awk -F ':| kB' '/MemTotal|MemFree|Buffers|Cached/ {printf $2}' /proc/meminfo ))
mem=$(awk -F ':' '/MemTotal|MemAvailable/ {printf $2}' /proc/meminfo ) memused=$((${mem[0]} - ${mem[1]} - ${mem[2]} - ${mem[3]}))
memory="$((memused / 1024))MB / $((${mem[0]} / 1024))MB"
# Do some substitution on each line
memtotal=${mem/kB*/kB}
memavail=${mem/${memtotal}}
memtotal=${memtotal/kB*}
memavail=${memavail/kB*}
memused=$((memtotal - memavail))
memory="$((memused / 1024))MB / $((memtotal / 1024))MB"
;; ;;
"Mac OS X") "Mac OS X")