mirror of
https://github.com/tw93/Mole.git
synced 2026-02-10 17:49:18 +00:00
Merge branch 'dev' into fix/harden-brew-uninstall
This commit is contained in:
@@ -420,8 +420,8 @@ readonly DATA_PROTECTED_BUNDLES=(
|
||||
"com.netease.163music" # NetEase Music
|
||||
|
||||
# Web Browsers (protect complex storage like IndexedDB, localStorage)
|
||||
"Firefox" # Firefox Application Support
|
||||
"org.mozilla.*" # Firefox bundle IDs
|
||||
"Firefox" # Firefox Application Support
|
||||
"org.mozilla.*" # Firefox bundle IDs
|
||||
|
||||
# License Management & App Stores
|
||||
"com.paddle.Paddle*" # Paddle (license management)
|
||||
@@ -665,6 +665,7 @@ find_app_files() {
|
||||
"$HOME/Library/HTTPStorages/$bundle_id"
|
||||
"$HOME/Library/Cookies/$bundle_id.binarycookies"
|
||||
"$HOME/Library/LaunchAgents/$bundle_id.plist"
|
||||
"$HOME/Library/LaunchDaemons/$bundle_id.plist"
|
||||
"$HOME/Library/Application Scripts/$bundle_id"
|
||||
"$HOME/Library/Services/$app_name.workflow"
|
||||
"$HOME/Library/QuickLook/$app_name.qlgenerator"
|
||||
@@ -739,11 +740,18 @@ find_app_files() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Launch Agents by name (special handling)
|
||||
if [[ ${#app_name} -gt 3 ]] && [[ -d ~/Library/LaunchAgents ]]; then
|
||||
while IFS= read -r -d '' plist; do
|
||||
files_to_clean+=("$plist")
|
||||
done < <(command find ~/Library/LaunchAgents -maxdepth 1 \( -name "*$app_name*.plist" \) -print0 2> /dev/null)
|
||||
# Launch Agents and Daemons by name (special handling)
|
||||
if [[ ${#app_name} -gt 3 ]]; then
|
||||
if [[ -d ~/Library/LaunchAgents ]]; then
|
||||
while IFS= read -r -d '' plist; do
|
||||
files_to_clean+=("$plist")
|
||||
done < <(command find ~/Library/LaunchAgents -maxdepth 1 \( -name "*$app_name*.plist" \) -print0 2> /dev/null)
|
||||
fi
|
||||
if [[ -d ~/Library/LaunchDaemons ]]; then
|
||||
while IFS= read -r -d '' plist; do
|
||||
files_to_clean+=("$plist")
|
||||
done < <(command find ~/Library/LaunchDaemons -maxdepth 1 \( -name "*$app_name*.plist" \) -print0 2> /dev/null)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Handle specialized toolchains and development environments
|
||||
|
||||
@@ -124,14 +124,14 @@ remove_apps_from_dock() {
|
||||
local changed=false
|
||||
for target in "${targets[@]}"; do
|
||||
local app_path="$target"
|
||||
local app_name
|
||||
app_name=$(basename "$app_path" .app)
|
||||
|
||||
# Normalize path for comparison - realpath might fail if app is already deleted
|
||||
local full_path
|
||||
full_path=$(cd "$(dirname "$app_path")" 2> /dev/null && pwd || echo "")
|
||||
[[ -n "$full_path" ]] && full_path="$full_path/$(basename "$app_path")"
|
||||
|
||||
# URL-encode the path for matching against Dock URLs (spaces -> %20)
|
||||
local encoded_path="${full_path// /%20}"
|
||||
|
||||
# Find the index of the app in persistent-apps
|
||||
local i=0
|
||||
while true; do
|
||||
@@ -141,16 +141,17 @@ remove_apps_from_dock() {
|
||||
|
||||
local url
|
||||
url=$(/usr/libexec/PlistBuddy -c "Print :persistent-apps:$i:tile-data:file-data:_CFURLString" "$plist" 2> /dev/null || echo "")
|
||||
[[ -z "$url" ]] && {
|
||||
((i++))
|
||||
continue
|
||||
}
|
||||
|
||||
# Match by label or by path (parsing the CFURLString which is usually a file:// URL)
|
||||
if [[ "$label" == "$app_name" ]] || [[ "$url" == *"$app_name.app"* ]]; then
|
||||
# Double check path if possible to avoid false positives for similarly named apps
|
||||
if [[ -n "$full_path" && "$url" == *"$full_path"* ]] || [[ "$label" == "$app_name" ]]; then
|
||||
if /usr/libexec/PlistBuddy -c "Delete :persistent-apps:$i" "$plist" 2> /dev/null; then
|
||||
changed=true
|
||||
# After deletion, current index i now points to the next item
|
||||
continue
|
||||
fi
|
||||
# Match by URL-encoded path to handle spaces in app names
|
||||
if [[ -n "$encoded_path" && "$url" == *"$encoded_path"* ]]; then
|
||||
if /usr/libexec/PlistBuddy -c "Delete :persistent-apps:$i" "$plist" 2> /dev/null; then
|
||||
changed=true
|
||||
# After deletion, current index i now points to the next item
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
((i++))
|
||||
|
||||
Reference in New Issue
Block a user