mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 17:24:45 +00:00
🎨 Uninstalling and cleaning is a cleaner experience
This commit is contained in:
79
bin/clean.sh
79
bin/clean.sh
@@ -257,65 +257,66 @@ safe_clean() {
|
||||
}
|
||||
|
||||
start_cleanup() {
|
||||
clear
|
||||
echo ""
|
||||
echo -e "${PURPLE}🧹 Clean Your Mac${NC}"
|
||||
echo ""
|
||||
echo "Mole will remove app caches, browser data, developer tools, and temporary files."
|
||||
echo ""
|
||||
|
||||
if [[ "$DRY_RUN" != "true" && -t 0 ]]; then
|
||||
echo -e "${BLUE}Tip:${NC} Want a preview first? Run 'mole clean --dry-run'."
|
||||
echo ""
|
||||
echo -e "${BLUE}Tip:${NC} Want a preview first? Run 'mole clean --dry-run'."
|
||||
fi
|
||||
|
||||
if [[ "$DRY_RUN" == "true" ]]; then
|
||||
echo ""
|
||||
echo -e "${YELLOW}🧪 Dry Run mode:${NC} showing what would be removed (no deletions)."
|
||||
echo ""
|
||||
SYSTEM_CLEAN=false
|
||||
return
|
||||
fi
|
||||
|
||||
local password=""
|
||||
if [[ -t 0 ]]; then
|
||||
echo "Enter admin password for system-level cleanup (or press Enter to skip):"
|
||||
echo -n "> "
|
||||
echo ""
|
||||
echo "System-level cleanup removes system caches and temp files, optional."
|
||||
echo -en "${BLUE}Enter admin password to enable, or press Enter to skip: ${NC}"
|
||||
read -s password
|
||||
echo ""
|
||||
else
|
||||
password=""
|
||||
echo ""
|
||||
echo -e "${BLUE}ℹ${NC} Running in non-interactive mode"
|
||||
echo " • System-level cleanup will be skipped (requires password)"
|
||||
echo " • User-level cleanup will proceed automatically"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ -n "$password" ]] && echo "$password" | sudo -S true 2>/dev/null; then
|
||||
SYSTEM_CLEAN=true
|
||||
# Start sudo keepalive with error handling and shorter intervals
|
||||
(
|
||||
local retry_count=0
|
||||
while true; do
|
||||
if ! sudo -n true 2>/dev/null; then
|
||||
((retry_count++))
|
||||
if [[ $retry_count -ge 3 ]]; then
|
||||
log_warning "Sudo keepalive failed, system-level cleanup may be interrupted" >&2
|
||||
exit 1
|
||||
|
||||
if [[ -n "$password" ]] && echo "$password" | sudo -S true 2>/dev/null; then
|
||||
SYSTEM_CLEAN=true
|
||||
# Start sudo keepalive with error handling
|
||||
(
|
||||
local retry_count=0
|
||||
while true; do
|
||||
if ! sudo -n true 2>/dev/null; then
|
||||
((retry_count++))
|
||||
if [[ $retry_count -ge 3 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
sleep 5
|
||||
continue
|
||||
fi
|
||||
sleep 5
|
||||
continue
|
||||
fi
|
||||
retry_count=0
|
||||
sleep 30
|
||||
kill -0 "$$" 2>/dev/null || exit
|
||||
done
|
||||
) 2>/dev/null &
|
||||
SUDO_KEEPALIVE_PID=$!
|
||||
log_info "Starting comprehensive cleanup with admin privileges..."
|
||||
retry_count=0
|
||||
sleep 30
|
||||
kill -0 "$$" 2>/dev/null || exit
|
||||
done
|
||||
) 2>/dev/null &
|
||||
SUDO_KEEPALIVE_PID=$!
|
||||
else
|
||||
SYSTEM_CLEAN=false
|
||||
if [[ -n "$password" ]]; then
|
||||
echo ""
|
||||
echo -e "${YELLOW}⚠️ Invalid password, continuing with user-level cleanup${NC}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
SYSTEM_CLEAN=false
|
||||
log_info "Starting user-level cleanup..."
|
||||
if [[ -n "$password" ]]; then
|
||||
echo -e "${YELLOW}⚠️ Invalid password, continuing with user-level cleanup${NC}"
|
||||
fi
|
||||
echo ""
|
||||
echo -e "${BLUE}ℹ${NC} Running in non-interactive mode"
|
||||
echo " • System-level cleanup skipped (requires interaction)"
|
||||
echo " • User-level cleanup will proceed automatically"
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -19,29 +19,29 @@ source "$SCRIPT_DIR/../lib/batch_uninstall.sh"
|
||||
|
||||
# Help information
|
||||
show_help() {
|
||||
echo "App Uninstaller"
|
||||
echo "==============="
|
||||
echo "Usage: mole uninstall"
|
||||
echo ""
|
||||
echo "Uninstall applications and clean their data completely."
|
||||
echo "Interactive application uninstaller - Remove apps completely"
|
||||
echo ""
|
||||
echo "Controls:"
|
||||
echo " ↑/↓ Navigate"
|
||||
echo " SPACE Select/deselect"
|
||||
echo " ENTER Confirm"
|
||||
echo " Q Quit"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " ./uninstall.sh Launch interactive uninstaller"
|
||||
echo " ./uninstall.sh --help Show this help message"
|
||||
echo "Keyboard Controls:"
|
||||
echo " ↑/↓ Navigate items"
|
||||
echo " Space Select/deselect"
|
||||
echo " Enter Confirm and uninstall"
|
||||
echo " Q / ESC Quit"
|
||||
echo ""
|
||||
echo "What gets cleaned:"
|
||||
echo " • Application bundle"
|
||||
echo " • Application Support data"
|
||||
echo " • Application Support data (12+ locations)"
|
||||
echo " • Cache files"
|
||||
echo " • Preference files"
|
||||
echo " • Log files"
|
||||
echo " • Saved application state"
|
||||
echo " • Container data (sandboxed apps)"
|
||||
echo " • WebKit storage, HTTP storage, cookies"
|
||||
echo " • Extensions, plugins, services"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " mole uninstall Launch interactive uninstaller"
|
||||
echo ""
|
||||
}
|
||||
|
||||
@@ -116,11 +116,13 @@ scan_applications() {
|
||||
|
||||
local temp_file=$(mktemp)
|
||||
|
||||
echo -n "Scanning... " >&2
|
||||
|
||||
# Pre-cache current epoch to avoid repeated calls
|
||||
local current_epoch=$(date "+%s")
|
||||
|
||||
# Spinner for scanning feedback
|
||||
local spinner_chars="⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"
|
||||
local spinner_idx=0
|
||||
|
||||
# First pass: quickly collect all valid app paths and bundle IDs
|
||||
local -a app_data_tuples=()
|
||||
while IFS= read -r -d '' app_path; do
|
||||
@@ -279,8 +281,10 @@ scan_applications() {
|
||||
process_app_metadata "$app_data_tuple" "$temp_file" "$current_epoch" &
|
||||
pids+=($!)
|
||||
|
||||
# Update progress
|
||||
echo -ne "\rScanning... $app_count/$total_apps" >&2
|
||||
# Update progress with spinner
|
||||
local spinner_char="${spinner_chars:$((spinner_idx % 10)):1}"
|
||||
echo -ne "\r🗑️ ${spinner_char} Scanning... $app_count/$total_apps" >&2
|
||||
((spinner_idx++))
|
||||
|
||||
# Wait if we've hit max parallel limit
|
||||
if (( ${#pids[@]} >= max_parallel )); then
|
||||
@@ -294,7 +298,8 @@ scan_applications() {
|
||||
wait "$pid" 2>/dev/null
|
||||
done
|
||||
|
||||
echo -e "\rFound $app_count applications ✓" >&2
|
||||
echo -e "\r🗑️ ✓ Found $app_count applications " >&2
|
||||
echo "" >&2
|
||||
|
||||
# Check if we found any applications
|
||||
if [[ ! -s "$temp_file" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user