Merge Windows/Linux memory functions
This commit is contained in:
parent
6fef7aa456
commit
e2ae78c898
15
neofetch
15
neofetch
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -x
|
||||||
# vim: fdm=marker:noai:ts=4:sw=4
|
# vim: fdm=marker:noai:ts=4:sw=4
|
||||||
#
|
#
|
||||||
# Neofetch info about your system
|
# Neofetch info about your system
|
||||||
|
@ -1089,7 +1090,7 @@ getgpu () {
|
||||||
|
|
||||||
getmemory () {
|
getmemory () {
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux")
|
"Linux" | "Windows")
|
||||||
mem=($(awk -F ':| kB' '/MemTotal|MemFree|Buffers|Cached/ {printf $2}' /proc/meminfo ))
|
mem=($(awk -F ':| kB' '/MemTotal|MemFree|Buffers|Cached/ {printf $2}' /proc/meminfo ))
|
||||||
memused=$((${mem[0]} - ${mem[1]} - ${mem[2]} - ${mem[3]}))
|
memused=$((${mem[0]} - ${mem[1]} - ${mem[2]} - ${mem[3]}))
|
||||||
memused=$((memused / 1024))
|
memused=$((memused / 1024))
|
||||||
|
@ -1130,17 +1131,6 @@ getmemory () {
|
||||||
esac
|
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
|
esac
|
||||||
memory="${memused}MB / ${memtotal}MB"
|
memory="${memused}MB / ${memtotal}MB"
|
||||||
|
|
||||||
|
@ -2471,6 +2461,7 @@ bar() {
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue