Merge pull request #500 from dylanaraps/freebsd_memfix
Memory: [BSD] Rewrite BSD memory function.
This commit is contained in:
commit
983968fa7c
1 changed files with 18 additions and 11 deletions
27
neofetch
27
neofetch
|
@ -1074,21 +1074,28 @@ get_memory() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"BSD")
|
"BSD")
|
||||||
|
# Mem total
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
"NetBSD"*)
|
"NetBSD"*) mem_total="$(($(sysctl -n hw.physmem64) / 1024 / 1024))" ;;
|
||||||
memfree="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))"
|
*) mem_total="$(($(sysctl -n hw.physmem) / 1024 / 1024))" ;;
|
||||||
mem_total="$(($(sysctl -n hw.physmem64) / 1024 / 1024))"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
memfree="$(($(vmstat | awk 'END{printf $5}') / 1024))"
|
|
||||||
mem_total="$(($(sysctl -n hw.physmem) / 1024 / 1024))"
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Mem free
|
||||||
|
case "$distro" in
|
||||||
|
"NetBSD"*) mem_free="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))" ;;
|
||||||
|
"FreeBSD"* | "DragonFly"*)
|
||||||
|
mem_free="$(top -d 1 | awk -F ',' '/^Mem:/ {print $5}')"
|
||||||
|
mem_free="${mem_free/M Free}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
"OpenBSD"*) ;;
|
||||||
|
*) mem_free="$(($(vmstat | awk 'END{printf $5}') / 1024))" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Mem used
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
"OpenBSD"*) mem_used="$(($(vmstat | awk 'END{printf $4}') / 1024))" ;;
|
"OpenBSD"*) mem_used="$(($(vmstat | awk 'END{printf $4}') / 1024))" ;;
|
||||||
*) mem_used="$((mem_total - memfree))" ;;
|
*) mem_used="$((mem_total - mem_free))" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue