diff options
| author | coasteen <coasteen@proton.me> | 2026-07-09 10:42:28 +0330 |
|---|---|---|
| committer | coasteen <coasteen@proton.me> | 2026-07-09 10:42:28 +0330 |
| commit | 8cbadb61604667b407b53ee1258433994fa4765a (patch) | |
| tree | 97765fb29418fd6278fcb4cbb9760893afaf7a58 /local/bin/sb-memory | |
Diffstat (limited to 'local/bin/sb-memory')
| -rwxr-xr-x | local/bin/sb-memory | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/local/bin/sb-memory b/local/bin/sb-memory new file mode 100755 index 0000000..282d6f7 --- /dev/null +++ b/local/bin/sb-memory @@ -0,0 +1,27 @@ +#!/bin/sh + +_openbsd() { + TOTAL="$(free | awk '/^Mem:/ {print $2}')" + MUSED="$(top -b -n 1 | grep -o 'Real.*' | sed 's/Real: //' | sed 's/\/.*//')" + printf "$MUSED" | egrep "[0-9]{4}" > /dev/null && FUSED="$(printf "$MUSED" | cut -c -2 | sed 's/./.&/2')G" || FUSED=$MUSED + printf "$FUSED/$TOTAL\n" +} + +_freebsd() { + TOTAL="$(freecolor -om | awk '/^Mem:/ {print $2}')" + MUSED="$(freecolor -om | awk '/^Mem:/ {print $3}')" + printf "$MUSED" | egrep "[0-9]{4}" > /dev/null && FUSED="$(printf "$MUSED" | cut -c -2 | sed 's/./.&/2')G" || FUSED=""$MUSED"M" + printf "$TOTAL" | egrep "[0-9]{4}" > /dev/null && TOTAL="$(printf "$TOTAL" | cut -c -2 | sed 's/./.&/2')G" || FUSED=$TOTAL + printf "$FUSED/$TOTAL\n" +} + +_linux() { + MUSED="$(free -m | awk '/^Mem:/ {print $3}')" + echo "$MUSED" +} + +case $(uname) in + Linux) _linux ;; + OpenBSD) _openbsd ;; + FreeBSD) _freebsd ;; +esac |
