Files
DynastyRevolution-Scripts/modules/system-info
Asainte Bueno-Villanueva 68617341c6
All checks were successful
Update Dispatches / refresh-news (push) Successful in 2s
add initial darwin (mac) support
apple popup support
2026-02-07 22:44:22 -05:00

49 lines
1.8 KiB
Bash

#!/bin/bash
# -----------------------------------------------------------------------
# Dynasty Module: Universal Pulse (v1.1 Dual-Native UI)
# -----------------------------------------------------------------------
# --- 1. OS Detection ---
if [[ "$OSTYPE" == "darwin"* ]]; then
OS="macOS"
# Mac specific: using sysctl and native uptime
CPU_LOAD=$(sysctl -n vm.loadavg | awk '{print $2}')
MEM_TOTAL=$(sysctl -n hw.memsize)
MEM_TOTAL_GB=$((MEM_TOTAL / 1024 / 1024 / 1024))
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_LOAD=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}')"%"
MEM_TOTAL_GB=$(free -g | awk '/^Mem:/{print $2}')
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
DASHBOARD="🐉 DYNASTY SYSTEM PULSE ($OS)
-------------------------------------
🕒 UPTIME: $UPTIME
🚀 CPU LOAD: $CPU_LOAD
🧠 MEMORY: ${MEM_TOTAL_GB}GB Total
💾 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
osascript -e "display dialog \"$DASHBOARD\" with title \"Dynasty Diagnostics\" buttons {\"Close\"} default button \"Close\"" >/dev/null 2>&1
else
# Native Linux Terminal Box
if command -v whiptail >/dev/null 2>&1; then
whiptail --title "Dynasty Diagnostics" --msgbox "$DASHBOARD" 15 50
else
clear
echo -e "$DASHBOARD"
echo ""
read -p "Press Enter to return to Dynasty..." < /dev/tty
fi
fi