diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2019-09-24 20:56:29 +0300 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2019-09-24 20:56:29 +0300 |
| commit | fe93178946e262db2e1a74750c17f729bf167128 (patch) | |
| tree | 93cd0960bb8e6a661b35f8019ad16a7a9a301d40 | |
| parent | 92fbf1d8107ffa84da08cb3fca9434f8b2c44975 (diff) | |
| download | pfetch-fe93178946e262db2e1a74750c17f729bf167128.tar.gz | |
memory: macOS and NetBSD support
| -rwxr-xr-x | pfetch | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -169,7 +169,7 @@ get_uptime() { ;; Darwin*|BSD*) - s=$(sysctl kern.boottime) + s=$(sysctl -n kern.boottime) # Extract the uptime in seconds from the following output: # [...] { sec = 1271934886, usec = 667779 } Thu Apr 22 12:14:46 2010 @@ -278,9 +278,28 @@ get_memory() { mem_used=$((mem_used / 1024)) mem_full=$((mem_full / 1024)) ;; + + Darwin*) + # If you run macOS and can send me the full output of + # 'vm_stat' I'll be able to add full support here. + mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024)) + ;; + + NetBSD*) + mem_full=$(($(sysctl -n hw.physmem64) / 1024 / 1024)) + + # NetBSD emulates a lot of the linux '/proc' filesystem. + # This is a simple loop adapted from the Linux memory + # detection. + while IFS=:kh read -r key val; do + [ "$key" = MemFree ] && mem_free=$val + done < /proc/meminfo + + mem_used=$((mem_full - (mem_free / 1024))) + ;; esac - log memory "${mem_used}MiB / ${mem_full}MiB" + log memory "${mem_used:-?}MiB / ${mem_full:-?}MiB" } get_ascii() { |
