From 16feb6955a4cc0248bca29ec4edf102d18e625a2 Mon Sep 17 00:00:00 2001 From: Asainte Bueno-Villanueva Date: Sun, 8 Feb 2026 00:03:22 -0500 Subject: [PATCH] add used memory to memory section --- modules/system-info | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/modules/system-info b/modules/system-info index c0b60fb..1f0bd10 100644 --- a/modules/system-info +++ b/modules/system-info @@ -3,41 +3,52 @@ # Dynasty Module: Universal Pulse (v1.1 Dual-Native UI) # ----------------------------------------------------------------------- -# --- 1. OS Detection --- +# --- 1. OS Detection & Metrics --- if [[ "$OSTYPE" == "darwin"* ]]; then OS="macOS" - # Mac specific: using sysctl and native uptime + # CPU: Get 1-minute load average CPU_LOAD=$(sysctl -n vm.loadavg | awk '{print $2}') - MEM_TOTAL=$(sysctl -n hw.memsize) - MEM_TOTAL_GB=$((MEM_TOTAL / 1024 / 1024 / 1024)) + + # MEMORY: Mac math (Total - Free = Used) + MEM_TOTAL_GB=$(($(sysctl -n hw.memsize) / 1024 / 1024 / 1024)) + PAGESIZE=$(pagesize) + PAGE_FREE=$(vm_stat | grep "Pages free" | awk '{print $3}' | sed 's/\.//') + MEM_FREE_GB=$((PAGE_FREE * PAGESIZE / 1024 / 1024 / 1024)) + MEM_USED_GB=$((MEM_TOTAL_GB - MEM_FREE_GB)) + + # OTHER UPTIME=$(uptime | sed -E 's/.*up ([^,]+),.*/\1/' | xargs) DISK=$(df -h / | awk 'NR==2 {print $5}') else OS="Linux" - # Linux specific: using free and top + # CPU: Percentage of non-idle time CPU_LOAD=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}')"%" + + # MEMORY: Using free in Gigabytes MEM_TOTAL_GB=$(free -g | awk '/^Mem:/{print $2}') + MEM_USED_GB=$(free -g | awk '/^Mem:/{print $3}') + + # OTHER UPTIME=$(uptime -p | sed 's/up //') DISK=$(df -h / | awk 'NR==2 {print $5}') fi # --- 2. Build the Dashboard --- -# Note: \n is handled differently by AppleScript vs Whiptail, so we format carefully +# Using standard dashes to prevent Gitea encoding warnings DASHBOARD="🐉 DYNASTY SYSTEM PULSE ($OS) ------------------------------------- 🕒 UPTIME: $UPTIME 🚀 CPU LOAD: $CPU_LOAD -🧠 MEMORY: ${MEM_TOTAL_GB}GB Total +🧠 MEMORY: ${MEM_USED_GB}GB / ${MEM_TOTAL_GB}GB 💾 DISK: $DISK Used -------------------------------------" # --- 3. Dual-Native Display --- if [[ "$OS" == "macOS" ]]; then - # Native macOS Popup Window - # We use quoted form of to handle special characters if necessary + # Native macOS Popup Window (Appears over all apps) osascript -e "display dialog \"$DASHBOARD\" with title \"Dynasty Diagnostics\" buttons {\"Close\"} default button \"Close\"" >/dev/null 2>&1 else - # Native Linux Terminal Box + # Native Linux Terminal Box (Whiptail with fallback) if command -v whiptail >/dev/null 2>&1; then whiptail --title "Dynasty Diagnostics" --msgbox "$DASHBOARD" 15 50 else