From 110d4851f974bb5d7afe5dd5493849474c861b19 Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Sat, 23 Dec 2023 20:14:17 -0700 Subject: [PATCH] Update memory calculation --- sway/swaybar_status.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sway/swaybar_status.sh b/sway/swaybar_status.sh index c59a854..4e2f95a 100755 --- a/sway/swaybar_status.sh +++ b/sway/swaybar_status.sh @@ -25,15 +25,15 @@ get_volume() { } remaining_ram() { - free --mega | awk '/Mem/ { - split($0, a, " ") + awk ' + /MemTotal:/ { memtotal = $2 / 1024**2 } + /MemAvailable:/ { mavailable = $2 / 1024**2 } - used = a[3] / 1000 - shared = a[5] / 1000 - available = a[7] / 1000 - - printf "%0.1fG / %.1fG", used + shared, available - }' + END { + used = memtotal - mavailable + printf "%0.1fG / %.1fG", used, memtotal + } +' /proc/meminfo } ramu="$(remaining_ram)"