Memory: Rename mem* to mem_*

This commit is contained in:
Dylan Araps 2016-11-17 01:04:01 +11:00
parent b3c27ade8d
commit 08502fa519

View file

@ -1020,62 +1020,62 @@ get_memory() {
# Source: https://github.com/KittyKatt/screenFetch/issues/386#issuecomment-249312716 # Source: https://github.com/KittyKatt/screenFetch/issues/386#issuecomment-249312716
while IFS=":" read -r a b; do while IFS=":" read -r a b; do
case "$a" in case "$a" in
"MemTotal") memused="$((memused+=${b/kB}))"; memtotal="${b/kB}" ;; "MemTotal") mem_used="$((mem_used+=${b/kB}))"; mem_total="${b/kB}" ;;
"Shmem") memused="$((memused+=${b/kB}))" ;; "Shmem") mem_used="$((mem_used+=${b/kB}))" ;;
"MemFree" | "Buffers" | "Cached" | "SReclaimable") memused="$((memused-=${b/kB}))" ;; "MemFree" | "Buffers" | "Cached" | "SReclaimable") mem_used="$((mem_used-=${b/kB}))" ;;
esac esac
done < /proc/meminfo done < /proc/meminfo
memused="$((memused / 1024))" mem_used="$((mem_used / 1024))"
memtotal="$((memtotal / 1024))" mem_total="$((mem_total / 1024))"
;; ;;
"Mac OS X" | "iPhone OS") "Mac OS X" | "iPhone OS")
memtotal="$(($(sysctl -n hw.memsize) / 1024^2))" mem_total="$(($(sysctl -n hw.memsize) / 1024^2))"
memwired="$(vm_stat | awk '/wired/ { print $4 }')" mem_wired="$(vm_stat | awk '/wired/ { print $4 }')"
memactive="$(vm_stat | awk '/active / { printf $3 }')" mem_active="$(vm_stat | awk '/active / { printf $3 }')"
memcompressed="$(vm_stat | awk '/occupied/ { printf $5 }')" mem_compressed="$(vm_stat | awk '/occupied/ { printf $5 }')"
memused="$(((${memwired//.} + ${memactive//.} + ${memcompressed//.}) * 4 / 1024))" mem_used="$(((${mem_wired//.} + ${mem_active//.} + ${mem_compressed//.}) * 4 / 1024))"
;; ;;
"BSD") "BSD")
case "$distro" in case "$distro" in
"NetBSD"*) "NetBSD"*)
memfree="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))" memfree="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))"
memtotal="$(($(sysctl -n hw.physmem64) / 1024^2))" mem_total="$(($(sysctl -n hw.physmem64) / 1024^2))"
;; ;;
*) *)
memfree="$(($(vmstat | awk 'END{printf $5}') / 1024))" memfree="$(($(vmstat | awk 'END{printf $5}') / 1024))"
memtotal="$(($(sysctl -n hw.physmem) / 1024^2))" mem_total="$(($(sysctl -n hw.physmem) / 1024^2))"
;; ;;
esac esac
case "$distro" in case "$distro" in
"OpenBSD"*) memused="$(($(vmstat | awk 'END {printf $4}') / 1024))" ;; "OpenBSD"*) mem_used="$(($(vmstat | awk 'END {printf $4}') / 1024))" ;;
*) memused="$((memtotal - memfree))" ;; *) mem_used="$((mem_total - memfree))" ;;
esac esac
;; ;;
"Solaris") "Solaris")
memtotal="$(prtconf | awk '/Memory/ {print $3}')" mem_total="$(prtconf | awk '/Memory/ {print $3}')"
memfree="$(($(sar -r 1 1 | awk 'NR==5 {print $2}') / 1024))" memfree="$(($(sar -r 1 1 | awk 'NR==5 {print $2}') / 1024))"
memused="$((memtotal - memfree))" mem_used="$((mem_total - memfree))"
;; ;;
"Haiku") "Haiku")
memtotal="$(($(sysinfo -mem | awk -F '\\/ |)' '{print $2; exit}') / 1024^2))" mem_total="$(($(sysinfo -mem | awk -F '\\/ |)' '{print $2; exit}') / 1024^2))"
memused="$(sysinfo -mem | awk -F '\\/|)' '{print $2; exit}')" mem_used="$(sysinfo -mem | awk -F '\\/|)' '{print $2; exit}')"
memused="$((${memused/max} / 1024^2))" mem_used="$((${mem_used/max} / 1024^2))"
;; ;;
esac esac
memory="${memused}MB / ${memtotal}MB" memory="${mem_used}MB / ${mem_total}MB"
# Bars # Bars
case "$memory_display" in case "$memory_display" in
"bar") memory="$(bar "${memused}" "${memtotal}")" ;; "bar") memory="$(bar "${mem_used}" "${mem_total}")" ;;
"infobar") memory="${memory} $(bar "${memused}" "${memtotal}")" ;; "infobar") memory="${memory} $(bar "${mem_used}" "${mem_total}")" ;;
"barinfo") memory="$(bar "${memused}" "${memtotal}") ${memory}" ;; "barinfo") memory="$(bar "${mem_used}" "${mem_total}") ${memory}" ;;
esac esac
} }