mirror of
https://github.com/tw93/Mole.git
synced 2026-02-08 05:04:23 +00:00
Add 'F' key to refresh paginated menus, clarify UI text for search and selection, and improve robustness of BOM file processing
This commit is contained in:
@@ -498,7 +498,12 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Interactive selection using paginated menu
|
# Interactive selection using paginated menu
|
||||||
if ! select_apps_for_uninstall; then
|
set +e
|
||||||
|
select_apps_for_uninstall
|
||||||
|
local exit_code=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ $exit_code -ne 0 ]]; then
|
||||||
if [[ "${MOLE_ALT_SCREEN_ACTIVE:-}" == "1" ]]; then
|
if [[ "${MOLE_ALT_SCREEN_ACTIVE:-}" == "1" ]]; then
|
||||||
leave_alt_screen
|
leave_alt_screen
|
||||||
unset MOLE_ALT_SCREEN_ACTIVE
|
unset MOLE_ALT_SCREEN_ACTIVE
|
||||||
@@ -508,6 +513,13 @@ main() {
|
|||||||
clear_screen
|
clear_screen
|
||||||
printf '\033[2J\033[H' >&2 # Also clear stderr
|
printf '\033[2J\033[H' >&2 # Also clear stderr
|
||||||
rm -f "$apps_file"
|
rm -f "$apps_file"
|
||||||
|
|
||||||
|
# Handle Refresh (code 10)
|
||||||
|
if [[ $exit_code -eq 10 ]]; then
|
||||||
|
force_rescan=true
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# User cancelled selection, exit the loop
|
# User cancelled selection, exit the loop
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -708,32 +708,34 @@ find_app_receipt_files() {
|
|||||||
done < <(find /private/var/db/receipts -name "${bundle_id}*.bom" -print0 2> /dev/null)
|
done < <(find /private/var/db/receipts -name "${bundle_id}*.bom" -print0 2> /dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for bom_file in "${bom_files[@]}"; do
|
# Process bom files if any found
|
||||||
[[ ! -f "$bom_file" ]] && continue
|
if [[ ${#bom_files[@]} -gt 0 ]]; then
|
||||||
|
for bom_file in "${bom_files[@]}"; do
|
||||||
|
[[ ! -f "$bom_file" ]] && continue
|
||||||
|
|
||||||
# Parse bom file
|
# Parse bom file
|
||||||
# lsbom -f: file paths only
|
# lsbom -f: file paths only
|
||||||
# -s: suppress output (convert to text)
|
# -s: suppress output (convert to text)
|
||||||
local bom_content
|
local bom_content
|
||||||
bom_content=$(lsbom -f -s "$bom_file" 2> /dev/null)
|
bom_content=$(lsbom -f -s "$bom_file" 2> /dev/null)
|
||||||
|
|
||||||
while IFS= read -r file_path; do
|
while IFS= read -r file_path; do
|
||||||
# Standardize path (remove leading dot)
|
# Standardize path (remove leading dot)
|
||||||
local clean_path="${file_path#.}"
|
local clean_path="${file_path#.}"
|
||||||
|
|
||||||
# Ensure it starts with /
|
# Ensure it starts with /
|
||||||
if [[ "$clean_path" != /* ]]; then
|
if [[ "$clean_path" != /* ]]; then
|
||||||
clean_path="/$clean_path"
|
clean_path="/$clean_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
# SAFETY FILTER: Only allow specific removal paths
|
# SAFETY FILTER: Only allow specific removal paths
|
||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
local is_safe=false
|
local is_safe=false
|
||||||
|
|
||||||
# Whitelisted prefixes
|
# Whitelisted prefixes
|
||||||
case "$clean_path" in
|
case "$clean_path" in
|
||||||
/Applications/*) is_safe=true ;;
|
/Applications/*) is_safe=true ;;
|
||||||
/Users/*) is_safe=true ;;
|
/Users/*) is_safe=true ;;
|
||||||
/usr/local/*) is_safe=true ;;
|
/usr/local/*) is_safe=true ;;
|
||||||
/opt/*) is_safe=true ;;
|
/opt/*) is_safe=true ;;
|
||||||
@@ -782,7 +784,7 @@ find_app_receipt_files() {
|
|||||||
|
|
||||||
done <<< "$bom_content"
|
done <<< "$bom_content"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
if [[ ${#receipt_files[@]} -gt 0 ]]; then
|
if [[ ${#receipt_files[@]} -gt 0 ]]; then
|
||||||
printf '%s\n' "${receipt_files[@]}"
|
printf '%s\n' "${receipt_files[@]}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -85,6 +85,11 @@ select_apps_for_uninstall() {
|
|||||||
unset MOLE_MENU_META_EPOCHS MOLE_MENU_META_SIZEKB
|
unset MOLE_MENU_META_EPOCHS MOLE_MENU_META_SIZEKB
|
||||||
# leave MOLE_MENU_SORT_DEFAULT untouched if user set it globally
|
# leave MOLE_MENU_SORT_DEFAULT untouched if user set it globally
|
||||||
|
|
||||||
|
# Refresh signal handling
|
||||||
|
if [[ $exit_code -eq 10 ]]; then
|
||||||
|
return 10
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $exit_code -ne 0 ]]; then
|
if [[ $exit_code -ne 0 ]]; then
|
||||||
echo "Cancelled"
|
echo "Cancelled"
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -474,11 +474,11 @@ paginated_multi_select() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Footer: single line with controls
|
# Footer: single line with controls
|
||||||
local sep=" ${GRAY}|${NC} "
|
local sep=" ${GRAY}|${NC} "
|
||||||
if [[ "$filter_mode" == "true" ]]; then
|
if [[ "$filter_mode" == "true" ]]; then
|
||||||
# Filter mode: simple controls without sort
|
# Filter mode: simple controls without sort
|
||||||
local -a _segs_filter=(
|
local -a _segs_filter=(
|
||||||
"${GRAY}Filter: ${filter_status}${NC}"
|
"${GRAY}Search: ${filter_status}${NC}"
|
||||||
"${GRAY}Delete${NC}"
|
"${GRAY}Delete${NC}"
|
||||||
"${GRAY}Enter Confirm${NC}"
|
"${GRAY}Enter Confirm${NC}"
|
||||||
"${GRAY}ESC Cancel${NC}"
|
"${GRAY}ESC Cancel${NC}"
|
||||||
@@ -490,7 +490,7 @@ paginated_multi_select() {
|
|||||||
[[ "$sort_reverse" == "true" ]] && reverse_arrow="↓"
|
[[ "$sort_reverse" == "true" ]] && reverse_arrow="↓"
|
||||||
|
|
||||||
# Determine filter text based on whether filter is active
|
# Determine filter text based on whether filter is active
|
||||||
local filter_text="/ Filter"
|
local filter_text="/ Search"
|
||||||
[[ -n "$applied_query" ]] && filter_text="/ Clear"
|
[[ -n "$applied_query" ]] && filter_text="/ Clear"
|
||||||
|
|
||||||
if [[ "$has_metadata" == "true" ]]; then
|
if [[ "$has_metadata" == "true" ]]; then
|
||||||
@@ -508,8 +508,9 @@ paginated_multi_select() {
|
|||||||
# Normal: show full controls
|
# Normal: show full controls
|
||||||
local -a _segs_all=(
|
local -a _segs_all=(
|
||||||
"${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN}${NC}"
|
"${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN}${NC}"
|
||||||
"${GRAY}Space${NC}"
|
"${GRAY}Space Select${NC}"
|
||||||
"${GRAY}Enter${NC}"
|
"${GRAY}Enter${NC}"
|
||||||
|
"${GRAY}F Refresh${NC}"
|
||||||
"${GRAY}${filter_text}${NC}"
|
"${GRAY}${filter_text}${NC}"
|
||||||
"${GRAY}S ${sort_status}${NC}"
|
"${GRAY}S ${sort_status}${NC}"
|
||||||
"${GRAY}R ${reverse_arrow}${NC}"
|
"${GRAY}R ${reverse_arrow}${NC}"
|
||||||
@@ -521,7 +522,7 @@ paginated_multi_select() {
|
|||||||
# Without metadata: basic controls
|
# Without metadata: basic controls
|
||||||
local -a _segs_simple=(
|
local -a _segs_simple=(
|
||||||
"${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN}${NC}"
|
"${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN}${NC}"
|
||||||
"${GRAY}Space${NC}"
|
"${GRAY}Space Select${NC}"
|
||||||
"${GRAY}Enter${NC}"
|
"${GRAY}Enter${NC}"
|
||||||
"${GRAY}${filter_text}${NC}"
|
"${GRAY}${filter_text}${NC}"
|
||||||
"${GRAY}Q Exit${NC}"
|
"${GRAY}Q Exit${NC}"
|
||||||
@@ -643,6 +644,10 @@ paginated_multi_select() {
|
|||||||
"CHAR:f" | "CHAR:F")
|
"CHAR:f" | "CHAR:F")
|
||||||
if [[ "$filter_mode" == "true" ]]; then
|
if [[ "$filter_mode" == "true" ]]; then
|
||||||
filter_query+="${key#CHAR:}"
|
filter_query+="${key#CHAR:}"
|
||||||
|
else
|
||||||
|
# Trigger Refresh signal
|
||||||
|
cleanup
|
||||||
|
return 10
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"CHAR:r")
|
"CHAR:r")
|
||||||
|
|||||||
2
mole
2
mole
@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
source "$SCRIPT_DIR/lib/core/common.sh"
|
source "$SCRIPT_DIR/lib/core/common.sh"
|
||||||
|
|
||||||
# Version info
|
# Version info
|
||||||
VERSION="1.12.13"
|
VERSION="1.12.14"
|
||||||
MOLE_TAGLINE="can dig deep to clean your Mac."
|
MOLE_TAGLINE="can dig deep to clean your Mac."
|
||||||
|
|
||||||
# Check if Touch ID is already configured
|
# Check if Touch ID is already configured
|
||||||
|
|||||||
Reference in New Issue
Block a user