Last active
December 7, 2023 08:13
-
-
Save thomaswitt/c5efaa6635356edfa0b204f05b260893 to your computer and use it in GitHub Desktop.
How to monitor and remove unwanted Launch Agents and Daemons in macOS (for .bash_profile)
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
# Remove unwanted helpers | |
process_agents() { | |
local directory=$1 | |
shift | |
local agents=("$@") | |
local pattern=$(IFS=\|; echo "${agents[*]}") | |
shopt -s nullglob | |
for plist in "$directory"/{LaunchAgents,LaunchDaemons,PrivilegedHelperTools}/*; do | |
if ! echo "$plist" | egrep -q "$pattern"; then | |
if [[ $directory = /Library* ]]; then | |
echo "sudo launchctl unload -w \"$plist\"" | |
echo -e "sudo rm -f \"$plist\"\n" | |
else | |
echo "launchctl unload -w \"$plist\"" | |
echo -e "rm -f \"$plist\"\n" | |
fi | |
fi | |
done | |
} | |
global_agents=( | |
at.obdev.littlesnitch # Little Snitch | |
com.docker # Docker | |
com.haystacksoftware # ARQ Backup | |
) | |
process_agents "/Library" "${global_agents[@]}" | |
local_agents=( | |
com.DigiDNA.iMazing # iMazing Backup | |
com.docker # Docker | |
) | |
process_agents "$HOME/Library" "${local_agents[@]}" | |
alias show_background_tasks='sudo sfltool dumpbtm|egrep "^\W+(#\d+|Disposition:|Identifier:)"|cut -c -80' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment