From e434a1e8372efaf6eec25bd4acfcdc49ccddd4a1 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sun, 4 Jan 2026 23:19:02 +0800 Subject: [PATCH] feat(uninstall): add support for third-party input methods - Add '/Library/Input Methods' to application scan paths - Unprotect Sogou, QQ, and Baidu input methods from system critical list - Enhance file cleanup logic to detect input method plugins and caches - Allow clean uninstallation and deep cleaning of WeType, Sogou, etc. --- lib/core/app_protection.sh | 23 ++++++++++++++--------- tests/core_common.bats | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/lib/core/app_protection.sh b/lib/core/app_protection.sh index 849a261..e07e209 100755 --- a/lib/core/app_protection.sh +++ b/lib/core/app_protection.sh @@ -50,17 +50,8 @@ readonly SYSTEM_CRITICAL_BUNDLES=( "KeyLayout*" "GlobalPreferences" ".GlobalPreferences" - # Input methods (critical for international users) - "com.tencent.inputmethod.QQInput" - "com.sogou.inputmethod.*" - "com.baidu.inputmethod.*" "com.apple.inputmethod.*" - "com.googlecode.rimeime.*" - "im.rime.*" "org.pqrs.Karabiner*" - "*.inputmethod" - "*.InputMethod" - "*IME" "com.apple.inputsource*" "com.apple.TextInputMenuAgent" "com.apple.TextInputSwitcher" @@ -68,6 +59,16 @@ readonly SYSTEM_CRITICAL_BUNDLES=( # Applications with sensitive data; protected during cleanup but removable readonly DATA_PROTECTED_BUNDLES=( + # Input Methods (protected during cleanup, uninstall allowed) + "com.tencent.inputmethod.QQInput" + "com.sogou.inputmethod.*" + "com.baidu.inputmethod.*" + "com.googlecode.rimeime.*" + "im.rime.*" + "*.inputmethod" + "*.InputMethod" + "*IME" + # System Utilities & Cleanup Tools "com.nektony.*" # App Cleaner & Uninstaller "com.macpaw.*" # CleanMyMac, CleanMaster @@ -663,6 +664,8 @@ find_app_files() { "$HOME/Library/Audio/Plug-Ins/VST3/$app_name.vst3" "$HOME/Library/Audio/Plug-Ins/Digidesign/$app_name.dpm" "$HOME/Library/PreferencePanes/$app_name.prefPane" + "$HOME/Library/Input Methods/$app_name.app" + "$HOME/Library/Input Methods/$bundle_id.app" "$HOME/Library/Screen Savers/$app_name.saver" "$HOME/Library/Frameworks/$app_name.framework" "$HOME/Library/Autosave Information/$bundle_id" @@ -798,6 +801,8 @@ find_app_system_files() { "/Library/Receipts/$bundle_id.plist" "/Library/Frameworks/$app_name.framework" "/Library/Internet Plug-Ins/$app_name.plugin" + "/Library/Input Methods/$app_name.app" + "/Library/Input Methods/$bundle_id.app" "/Library/Audio/Plug-Ins/Components/$app_name.component" "/Library/Audio/Plug-Ins/VST/$app_name.vst" "/Library/Audio/Plug-Ins/VST3/$app_name.vst3" diff --git a/tests/core_common.bats b/tests/core_common.bats index 0bb6efa..5b2d88e 100644 --- a/tests/core_common.bats +++ b/tests/core_common.bats @@ -146,6 +146,20 @@ EOF [ "$result" = "not-protected" ] } +@test "input methods are protected during cleanup but allowed for uninstall" { + result=$(HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/core/common.sh'; should_protect_data 'com.tencent.inputmethod.QQInput' && echo 'protected' || echo 'not-protected'") + [ "$result" = "protected" ] + + result=$(HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/core/common.sh'; should_protect_data 'com.sogou.inputmethod.pinyin' && echo 'protected' || echo 'not-protected'") + [ "$result" = "protected" ] + + result=$(HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/core/common.sh'; should_protect_from_uninstall 'com.tencent.inputmethod.QQInput' && echo 'protected' || echo 'not-protected'") + [ "$result" = "not-protected" ] + + result=$(HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/core/common.sh'; should_protect_from_uninstall 'com.apple.inputmethod.SCIM' && echo 'protected' || echo 'not-protected'") + [ "$result" = "protected" ] +} + @test "print_summary_block formats output correctly" { result=$(HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/core/common.sh'; print_summary_block 'success' 'Test Summary' 'Detail 1' 'Detail 2'") [[ "$result" == *"Test Summary"* ]]