aboutsummaryrefslogtreecommitdiff
path: root/common/.config/sketchybar/plugins/mem.sh.org
diff options
context:
space:
mode:
authorJacob Janzen <jacob.a.s.janzen@gmail.com>2024-10-01 17:42:59 -0500
committerJacob Janzen <jacob.a.s.janzen@gmail.com>2024-10-01 17:42:59 -0500
commit7b0ea5cbdaaa5b8392777ad207c74cb27411eab1 (patch)
tree37a3438116ec3c84663133c820808ad9e2acf021 /common/.config/sketchybar/plugins/mem.sh.org
parent7a347653dfad8c6c33791f7e72a4ec40b8230ac3 (diff)
the big refactor
Diffstat (limited to 'common/.config/sketchybar/plugins/mem.sh.org')
-rwxr-xr-xcommon/.config/sketchybar/plugins/mem.sh.org16
1 files changed, 16 insertions, 0 deletions
diff --git a/common/.config/sketchybar/plugins/mem.sh.org b/common/.config/sketchybar/plugins/mem.sh.org
new file mode 100755
index 0000000..ef3feef
--- /dev/null
+++ b/common/.config/sketchybar/plugins/mem.sh.org
@@ -0,0 +1,16 @@
+#+title: SketchyBar Memory Plugin
+
+Get the memory in use and return that as a percent.
+#+begin_src sh :tangle ~/.config/sketchybar/plugins/mem.sh :mkdirp yes :tangle-mode o755
+ #!/bin/sh
+ hw_pagesize="$(sysctl -n hw.pagesize)"
+ mem_total="$(($(sysctl -n hw.memsize) / 1024))"
+ pages_app="$(($(sysctl -n vm.page_pageable_internal_count) - $(sysctl -n vm.page_purgeable_count)))"
+ pages_wired="$(vm_stat | awk '/ wired/ { print $4 }')"
+ pages_compressed="$(vm_stat | awk '/ occupied/ { printf $5 }')"
+ pages_compressed="${pages_compressed:-0}"
+ mem_used="$(((pages_app + ${pages_wired//.} + ${pages_compressed//.}) * hw_pagesize / 1024))"
+
+ mem_percent=$((mem_perc=$mem_used * 100 / $mem_total))
+ sketchybar --set "$NAME" icon="󰆼" label="$mem_percent%"
+#+end_src