this time it surely works on bsd
This commit is contained in:
parent
4303cf2e00
commit
90b26dc5e0
@ -14,11 +14,19 @@ get_mem_info() {
|
||||
|
||||
# macOS / BSD via sysctl
|
||||
if command -v sysctl >/dev/null 2>&1; then
|
||||
|
||||
# total memory
|
||||
mem_total=$(sysctl -n hw.memsize 2>/dev/null)
|
||||
if [ -n "$mem_total" ]; then
|
||||
# convert bytes → kB
|
||||
mem_total=$(expr "$mem_total" / 1024)
|
||||
mem_total_bytes=$(
|
||||
sysctl -n hw.memsize 2>/dev/null || \
|
||||
sysctl -n hw.realmem 2>/dev/null || \
|
||||
sysctl -n hw.physmem 2>/dev/null || \
|
||||
sysctl -n hw.physmem64 2>/dev/null
|
||||
)
|
||||
|
||||
if [ -n "$mem_total_bytes" ] 2>/dev/null; then
|
||||
mem_total=$(expr "$mem_total_bytes" / 1024) # convert to kB
|
||||
else
|
||||
mem_total=""
|
||||
fi
|
||||
|
||||
# available memory varies by OS; fallback to inactive + free
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user