mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 03:46:11 +00:00
fix(uninstall): fix Dock cleanup by using correct PlistBuddy path
- Changed from `command -v PlistBuddy` to `[[ -x /usr/libexec/PlistBuddy ]]` - PlistBuddy is not in PATH, it's at /usr/libexec/PlistBuddy on macOS - Previous code would always return early, making Dock cleanup never work - Also improved fallback logic for already-deleted apps - Tested and verified Dock icons are now properly removed after uninstall
This commit is contained in:
@@ -119,15 +119,28 @@ remove_apps_from_dock() {
|
|||||||
local plist="$HOME/Library/Preferences/com.apple.dock.plist"
|
local plist="$HOME/Library/Preferences/com.apple.dock.plist"
|
||||||
[[ -f "$plist" ]] || return 0
|
[[ -f "$plist" ]] || return 0
|
||||||
|
|
||||||
command -v PlistBuddy > /dev/null 2>&1 || return 0
|
# PlistBuddy is at /usr/libexec/PlistBuddy on macOS
|
||||||
|
[[ -x /usr/libexec/PlistBuddy ]] || return 0
|
||||||
|
|
||||||
local changed=false
|
local changed=false
|
||||||
for target in "${targets[@]}"; do
|
for target in "${targets[@]}"; do
|
||||||
local app_path="$target"
|
local app_path="$target"
|
||||||
# Normalize path for comparison - realpath might fail if app is already deleted
|
# Normalize path for comparison - use original path if app already deleted
|
||||||
local full_path
|
local full_path
|
||||||
full_path=$(cd "$(dirname "$app_path")" 2> /dev/null && pwd || echo "")
|
if full_path=$(cd "$(dirname "$app_path")" 2> /dev/null && pwd); then
|
||||||
[[ -n "$full_path" ]] && full_path="$full_path/$(basename "$app_path")"
|
full_path="$full_path/$(basename "$app_path")"
|
||||||
|
else
|
||||||
|
# App already deleted - use the original path as-is
|
||||||
|
# Remove ~/ prefix and expand to full path if needed
|
||||||
|
if [[ "$app_path" == ~/* ]]; then
|
||||||
|
full_path="$HOME/${app_path#~/}"
|
||||||
|
elif [[ "$app_path" != /* ]]; then
|
||||||
|
# Relative path - skip this entry
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
full_path="$app_path"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# URL-encode the path for matching against Dock URLs (spaces -> %20)
|
# URL-encode the path for matching against Dock URLs (spaces -> %20)
|
||||||
local encoded_path="${full_path// /%20}"
|
local encoded_path="${full_path// /%20}"
|
||||||
|
|||||||
Reference in New Issue
Block a user