1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-12 06:29:00 +00:00

Standardize check icons and add internal section headers for better visual hierarchy

This commit is contained in:
Tw93
2025-12-27 10:16:17 +08:00
parent 4c7fa894e1
commit 01dd879077

View File

@@ -35,7 +35,7 @@ check_touchid_sudo() {
# Check if Touch ID is configured for sudo # Check if Touch ID is configured for sudo
local pam_file="/etc/pam.d/sudo" local pam_file="/etc/pam.d/sudo"
if [[ -f "$pam_file" ]] && grep -q "pam_tid.so" "$pam_file" 2> /dev/null; then if [[ -f "$pam_file" ]] && grep -q "pam_tid.so" "$pam_file" 2> /dev/null; then
echo -e " ${GREEN}${NC} Touch ID Enabled for sudo" echo -e " ${GREEN}${NC} Touch ID Biometric authentication enabled"
else else
# Check if Touch ID is supported # Check if Touch ID is supported
local is_supported=false local is_supported=false
@@ -48,7 +48,7 @@ check_touchid_sudo() {
fi fi
if [[ "$is_supported" == "true" ]]; then if [[ "$is_supported" == "true" ]]; then
echo -e " ${YELLOW}${ICON_WARNING}${NC} Touch ID ${YELLOW}Not configured${NC} for sudo" echo -e " ${YELLOW}${ICON_WARNING}${NC} Touch ID ${YELLOW}Not configured for sudo${NC}"
export TOUCHID_NOT_CONFIGURED=true export TOUCHID_NOT_CONFIGURED=true
fi fi
fi fi
@@ -60,9 +60,9 @@ check_rosetta() {
# Check Rosetta 2 (for Apple Silicon Macs) # Check Rosetta 2 (for Apple Silicon Macs)
if [[ "$(uname -m)" == "arm64" ]]; then if [[ "$(uname -m)" == "arm64" ]]; then
if [[ -f "/Library/Apple/usr/share/rosetta/rosetta" ]]; then if [[ -f "/Library/Apple/usr/share/rosetta/rosetta" ]]; then
echo -e " ${GREEN}${NC} Rosetta 2 Installed" echo -e " ${GREEN}${NC} Rosetta 2 Intel app translation ready"
else else
echo -e " ${YELLOW}${ICON_WARNING}${NC} Rosetta 2 ${YELLOW}Not installed${NC}" echo -e " ${YELLOW}${ICON_WARNING}${NC} Rosetta 2 ${YELLOW}Intel app support missing${NC}"
export ROSETTA_NOT_INSTALLED=true export ROSETTA_NOT_INSTALLED=true
fi fi
fi fi
@@ -77,14 +77,15 @@ check_git_config() {
local git_email=$(git config --global user.email 2> /dev/null || echo "") local git_email=$(git config --global user.email 2> /dev/null || echo "")
if [[ -n "$git_name" && -n "$git_email" ]]; then if [[ -n "$git_name" && -n "$git_email" ]]; then
echo -e " ${GREEN}${NC} Git Config Configured" echo -e " ${GREEN}${NC} Git Global identity configured"
else else
echo -e " ${YELLOW}${ICON_WARNING}${NC} Git Config ${YELLOW}Not configured${NC}" echo -e " ${YELLOW}${ICON_WARNING}${NC} Git ${YELLOW}User identity not set${NC}"
fi fi
fi fi
} }
check_all_config() { check_all_config() {
echo -e "${BLUE}${ICON_ARROW}${NC} System Configuration"
check_touchid_sudo check_touchid_sudo
check_rosetta check_rosetta
check_git_config check_git_config
@@ -101,9 +102,9 @@ check_filevault() {
if command -v fdesetup > /dev/null 2>&1; then if command -v fdesetup > /dev/null 2>&1; then
local fv_status=$(fdesetup status 2> /dev/null || echo "") local fv_status=$(fdesetup status 2> /dev/null || echo "")
if echo "$fv_status" | grep -q "FileVault is On"; then if echo "$fv_status" | grep -q "FileVault is On"; then
echo -e " ${GREEN}${NC} FileVault Enabled" echo -e " ${GREEN}${NC} FileVault Disk encryption active"
else else
echo -e " ${RED}${NC} FileVault ${RED}Disabled${NC} (Recommend enabling)" echo -e " ${RED}${NC} FileVault ${RED}Disk encryption disabled${NC}"
export FILEVAULT_DISABLED=true export FILEVAULT_DISABLED=true
fi fi
fi fi
@@ -116,11 +117,9 @@ check_firewall() {
unset FIREWALL_DISABLED unset FIREWALL_DISABLED
local firewall_status=$(defaults read /Library/Preferences/com.apple.alf globalstate 2> /dev/null || echo "0") local firewall_status=$(defaults read /Library/Preferences/com.apple.alf globalstate 2> /dev/null || echo "0")
if [[ "$firewall_status" == "1" || "$firewall_status" == "2" ]]; then if [[ "$firewall_status" == "1" || "$firewall_status" == "2" ]]; then
echo -e " ${GREEN}${NC} Firewall Enabled" echo -e " ${GREEN}${NC} Firewall Network protection enabled"
else else
echo -e " ${YELLOW}${ICON_WARNING}${NC} Firewall ${YELLOW}Disabled${NC} (Consider enabling)" echo -e " ${YELLOW}${ICON_WARNING}${NC} Firewall ${YELLOW}Network protection disabled${NC}"
echo -e " ${GRAY}System Settings → Network → Firewall, or run:${NC}"
echo -e " ${GRAY}sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 1${NC}"
export FIREWALL_DISABLED=true export FIREWALL_DISABLED=true
fi fi
} }
@@ -132,12 +131,10 @@ check_gatekeeper() {
if command -v spctl > /dev/null 2>&1; then if command -v spctl > /dev/null 2>&1; then
local gk_status=$(spctl --status 2> /dev/null || echo "") local gk_status=$(spctl --status 2> /dev/null || echo "")
if echo "$gk_status" | grep -q "enabled"; then if echo "$gk_status" | grep -q "enabled"; then
echo -e " ${GREEN}${NC} Gatekeeper Active" echo -e " ${GREEN}${NC} Gatekeeper App download protection active"
unset GATEKEEPER_DISABLED unset GATEKEEPER_DISABLED
else else
echo -e " ${YELLOW}${ICON_WARNING}${NC} Gatekeeper ${YELLOW}Disabled${NC}" echo -e " ${YELLOW}${ICON_WARNING}${NC} Gatekeeper ${YELLOW}App security disabled${NC}"
echo -e " ${GRAY}Enable via System Settings → Privacy & Security, or:${NC}"
echo -e " ${GRAY}sudo spctl --master-enable${NC}"
export GATEKEEPER_DISABLED=true export GATEKEEPER_DISABLED=true
fi fi
fi fi
@@ -150,15 +147,15 @@ check_sip() {
if command -v csrutil > /dev/null 2>&1; then if command -v csrutil > /dev/null 2>&1; then
local sip_status=$(csrutil status 2> /dev/null || echo "") local sip_status=$(csrutil status 2> /dev/null || echo "")
if echo "$sip_status" | grep -q "enabled"; then if echo "$sip_status" | grep -q "enabled"; then
echo -e " ${GREEN}${NC} SIP Enabled" echo -e " ${GREEN}${NC} SIP System integrity protected"
else else
echo -e " ${YELLOW}${ICON_WARNING}${NC} SIP ${YELLOW}Disabled${NC}" echo -e " ${YELLOW}${ICON_WARNING}${NC} SIP ${YELLOW}System protection disabled${NC}"
echo -e " ${GRAY}Restart into Recovery → Utilities → Terminal → run: csrutil enable${NC}"
fi fi
fi fi
} }
check_all_security() { check_all_security() {
echo -e "${BLUE}${ICON_ARROW}${NC} Security Status"
check_filevault check_filevault
check_firewall check_firewall
check_gatekeeper check_gatekeeper
@@ -244,7 +241,7 @@ check_macos_update() {
local sw_status=0 local sw_status=0
local spinner_started=false local spinner_started=false
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
start_inline_spinner "Checking macOS updates..." MOLE_SPINNER_PREFIX=" " start_inline_spinner "Checking macOS updates..."
spinner_started=true spinner_started=true
fi fi
@@ -269,7 +266,7 @@ check_macos_update() {
if [[ "$updates_available" == "true" ]]; then if [[ "$updates_available" == "true" ]]; then
echo -e " ${YELLOW}${ICON_WARNING}${NC} macOS ${YELLOW}Update available${NC}" echo -e " ${YELLOW}${ICON_WARNING}${NC} macOS ${YELLOW}Update available${NC}"
else else
echo -e " ${GREEN}${NC} macOS Up to date" echo -e " ${GREEN}${NC} macOS System up to date"
fi fi
} }
@@ -294,7 +291,7 @@ check_mole_update() {
else else
# Show spinner while checking # Show spinner while checking
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
start_inline_spinner "Checking Mole version..." MOLE_SPINNER_PREFIX=" " start_inline_spinner "Checking Mole version..."
fi fi
# Try to get latest version from GitHub # Try to get latest version from GitHub
@@ -323,13 +320,12 @@ check_mole_update() {
# Compare versions # Compare versions
if [[ "$(printf '%s\n' "$current_version" "$latest_version" | sort -V | head -1)" == "$current_version" ]]; then if [[ "$(printf '%s\n' "$current_version" "$latest_version" | sort -V | head -1)" == "$current_version" ]]; then
export MOLE_UPDATE_AVAILABLE="true" export MOLE_UPDATE_AVAILABLE="true"
echo -e " ${YELLOW}${ICON_WARNING}${NC} Mole ${YELLOW}${latest_version} available${NC} (current: ${current_version})" echo -e " ${YELLOW}${ICON_WARNING}${NC} Mole ${YELLOW}${latest_version} available${NC} (running ${current_version})"
echo -e " ${GRAY}Run: ${GREEN}mo update${NC}"
else else
echo -e " ${GREEN}${NC} Mole Up to date (${current_version})" echo -e " ${GREEN}${NC} Mole Latest version ${current_version}"
fi fi
else else
echo -e " ${GREEN}${NC} Mole Up to date (${current_version})" echo -e " ${GREEN}${NC} Mole Latest version ${current_version}"
fi fi
} }
@@ -341,6 +337,7 @@ check_all_updates() {
# Only redirect stdout, keep stderr for spinner display # Only redirect stdout, keep stderr for spinner display
get_software_updates > /dev/null get_software_updates > /dev/null
echo -e "${BLUE}${ICON_ARROW}${NC} System Updates"
check_appstore_updates check_appstore_updates
check_macos_update check_macos_update
check_mole_update check_mole_update
@@ -448,7 +445,7 @@ check_login_items() {
if [[ -t 0 ]]; then if [[ -t 0 ]]; then
# Show spinner while getting login items # Show spinner while getting login items
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
start_inline_spinner "Checking login items..." MOLE_SPINNER_PREFIX=" " start_inline_spinner "Checking login items..."
fi fi
while IFS= read -r login_item; do while IFS= read -r login_item; do
@@ -463,16 +460,16 @@ check_login_items() {
fi fi
if [[ $login_items_count -gt 15 ]]; then if [[ $login_items_count -gt 15 ]]; then
echo -e " ${YELLOW}${ICON_WARNING}${NC} Login Items ${YELLOW}${login_items_count} apps${NC} auto-start (High)" echo -e " ${YELLOW}${ICON_WARNING}${NC} Login Items ${YELLOW}${login_items_count} apps${NC}"
elif [[ $login_items_count -gt 0 ]]; then elif [[ $login_items_count -gt 0 ]]; then
echo -e " ${GREEN}${NC} Login Items ${login_items_count} apps auto-start" echo -e " ${GREEN}${NC} Login Items ${login_items_count} apps"
else else
echo -e " ${GREEN}${NC} Login Items None" echo -e " ${GREEN}${NC} Login Items None"
return return
fi fi
# Show items in a single line # Show items in a single line (compact)
local preview_limit=5 local preview_limit=3
((preview_limit > login_items_count)) && preview_limit=$login_items_count ((preview_limit > login_items_count)) && preview_limit=$login_items_count
local items_display="" local items_display=""
@@ -486,11 +483,10 @@ check_login_items() {
if ((login_items_count > preview_limit)); then if ((login_items_count > preview_limit)); then
local remaining=$((login_items_count - preview_limit)) local remaining=$((login_items_count - preview_limit))
items_display="${items_display}, and ${remaining} more" items_display="${items_display} +${remaining}"
fi fi
echo -e " ${GRAY}${items_display}${NC}" echo -e " ${GRAY}${items_display}${NC}"
echo -e " ${GRAY}Manage in System Settings → Login Items${NC}"
} }
check_cache_size() { check_cache_size() {
@@ -504,7 +500,7 @@ check_cache_size() {
# Show spinner while calculating cache size # Show spinner while calculating cache size
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
start_inline_spinner "Scanning cache..." MOLE_SPINNER_PREFIX=" " start_inline_spinner "Scanning cache..."
fi fi
for cache_path in "${cache_paths[@]}"; do for cache_path in "${cache_paths[@]}"; do
@@ -564,6 +560,7 @@ check_brew_health() {
} }
check_system_health() { check_system_health() {
echo -e "${BLUE}${ICON_ARROW}${NC} System Health"
check_disk_space check_disk_space
check_memory_usage check_memory_usage
check_swap_usage check_swap_usage