Last active
April 27, 2021 19:59
-
-
Save gongzhang/cf93ae045b650d99581f9e826b84a23e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# 查杀/恢复 CleanMyMac 的流氓后台 HealthMonitor | |
# | |
# - 执行脚本后,原 HealthMonitor.app 会被备份并被空目录替代,然后杀掉后台进程(你直接杀是杀不净的)。此时 CleanMyMac 主应用也不能运行。 | |
# - 再次执行脚本,则将备份的文件恢复回去,CleanMyMac 则可以正常使用。 | |
# | |
# NOTE: 如果不是 Setapp 版本,进程名可能不同,需要自行修改下面变量: | |
MONITOR_DIR="/Applications/Setapp/CleanMyMac X.app/Contents/Library/LoginItems/CleanMyMac Menu.app/Contents/Library/LoginItems" | |
MONITOR_APP="CleanMyMac X HealthMonitor.app" | |
MONITOR_APP_BAK="CleanMyMac X HealthMonitor.app.bak" | |
MONITOR_PROCESS_KEYWORD="CleanMyMac-setapp.HealthMonitor" | |
# 确保路径和文件名正确 | |
cd "$MONITOR_DIR" | |
test -d "$MONITOR_APP" || (echo "$MONITOR_APP not found"; exit 1) | |
if [ -e "$MONITOR_APP_BAK" ] | |
then | |
# 已经有备份,恢复原 app 文件 | |
echo "recover original HealthMonitor app..." | |
rm -rf "$MONITOR_APP" | |
mv "$MONITOR_APP_BAK" "$MONITOR_APP" | |
echo "done." | |
else | |
# 备份原 app 文件,并用空文件夹代替 | |
echo "rename original HealthMonitor app..." | |
mv "$MONITOR_APP" "$MONITOR_APP_BAK" | |
mkdir "$MONITOR_APP" | |
chmod 644 "$MONITOR_APP" | |
# 查杀进程 | |
echo "kill running HealthMonitor process..." | |
hm_pid=$(ps aux|grep "$MONITOR_PROCESS_KEYWORD"|grep -v grep|awk '{print $2}') | |
if [ -z "$hm_pid" ]; then | |
echo 'HealthMonitor process not found ' | |
else | |
kill -9 $hm_pid | |
echo "HealthMonitor process killed! ($hm_pid)" | |
fi | |
echo "done." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
脚本已失效直接卸载 CleanMyMac 吧,这个流氓后台即关不掉,也 kill 不掉;无论是从 launchd unload 还是直接移除可执行文件都不起作用。已更新为切换脚本
执行脚本可禁用和恢复后台程序 HealthMonitor。(当前版本的 CleanMyMac 主应用依赖 HealthMonitor 故不能一棒子打死)