From aa6f6c503f0b3f82cd053aae73b991833b33ab56 Mon Sep 17 00:00:00 2001 From: tw93 Date: Sat, 31 Jan 2026 17:39:54 +0800 Subject: [PATCH] refactor: add feedback for fallback Trash cleanup Improve user experience when osascript fails to empty Trash: - Count successfully cleaned items - Display cleanup confirmation message - Only show message if items were actually cleaned - Call note_activity to record the cleanup This ensures users get consistent feedback regardless of which cleanup method is used (osascript vs find fallback). --- lib/clean/user.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/clean/user.sh b/lib/clean/user.sh index 662fd07..99b6f7b 100644 --- a/lib/clean/user.sh +++ b/lib/clean/user.sh @@ -20,9 +20,16 @@ clean_user_essentials() { echo -e " ${GREEN}${ICON_SUCCESS}${NC} Trash · emptied, $trash_count items" note_activity else + local cleaned_count=0 while IFS= read -r -d '' item; do - safe_remove "$item" true || true + if safe_remove "$item" true; then + ((cleaned_count++)) + fi done < <(command find "$HOME/.Trash" -mindepth 1 -maxdepth 1 -print0 2> /dev/null || true) + if [[ $cleaned_count -gt 0 ]]; then + echo -e " ${GREEN}${ICON_SUCCESS}${NC} Trash · emptied, $cleaned_count items" + note_activity + fi fi else echo -e " ${GREEN}${ICON_SUCCESS}${NC} Trash · already empty"