Merge pull request #193 from dylanaraps/windows_mem

Merge Linux and Windows memory functions.
This commit is contained in:
Dylan Araps 2016-03-28 09:52:28 +11:00
commit 347a927fe4

View file

@ -1089,8 +1089,8 @@ getgpu () {
getmemory () {
case "$os" in
"Linux")
mem=($(awk -F ':| kB' '/MemTotal|MemFree|Buffers|Cached/ {printf $2}' /proc/meminfo ))
"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]}))
memused=$((memused / 1024))
memtotal=$((${mem[0]} / 1024))
@ -1130,17 +1130,6 @@ getmemory () {
esac
;;
"Windows")
mem="$(awk 'NR < 3 {printf $2 " "}' /proc/meminfo)"
memtotal=${mem/ *}
memfree=${mem#* }
memavail=$((memtotal - memfree))
memused=$((memtotal - memavail))
memused=$((${memused%% *} / 1024))
memtotal=$((${memtotal%% *} / 1024))
;;
esac
memory="${memused}MB / ${memtotal}MB"
@ -2471,6 +2460,7 @@ bar() {
# }}}
# }}}