From 9e1d09cb938c057a8590eeb47ea4452273972576 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Thu, 15 Jan 2026 11:40:49 +0800 Subject: [PATCH] fix: handle spaces in dock item removal - URL-encode paths when matching against Dock persistent-apps - Fixes issue where apps with spaces in names (e.g. 'Clash Party') were not removed from Dock --- lib/core/common.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/core/common.sh b/lib/core/common.sh index cc74c63..6e847ab 100755 --- a/lib/core/common.sh +++ b/lib/core/common.sh @@ -182,6 +182,9 @@ remove_apps_from_dock() { 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 @@ -196,8 +199,8 @@ remove_apps_from_dock() { continue } - # Match by full path only to avoid removing apps with the same label. - if [[ -n "$full_path" && "$url" == *"$full_path"* ]]; then + # 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