1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 17:55:08 +00:00

refactor(base): extract get_lsregister_path as shared utility

Move get_lsregister_path() to base.sh to avoid duplication across
optimize and uninstall modules. Adds macOS 14+ compatibility with
fallback paths.
This commit is contained in:
tw93
2026-02-26 11:53:39 +08:00
parent f394e7552c
commit 88b0fe6af3

View File

@@ -43,6 +43,27 @@ readonly ICON_NAV_UP="↑"
readonly ICON_NAV_DOWN="↓"
readonly ICON_INFO=""
# ============================================================================
# LaunchServices Utility
# ============================================================================
# Locate the lsregister binary (path varies across macOS versions).
get_lsregister_path() {
local -a candidates=(
"/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister"
"/System/Library/CoreServices/Frameworks/LaunchServices.framework/Support/lsregister"
)
local candidate=""
for candidate in "${candidates[@]}"; do
if [[ -x "$candidate" ]]; then
echo "$candidate"
return 0
fi
done
echo ""
return 0
}
# ============================================================================
# Global Configuration Constants
# ============================================================================