Many macOS software installers add unnecessary background processes, such as auto-updaters, which can be intrusive or even spyware. These “helpers” typically install in the directories: LaunchAgents, LaunchDaemons, or PrivilegedHelperTools, found in /Library or $HOME/Library. To find and potentially remove them, you have to check these locations regularly.
I created a script for my .bash_profile or .zshrc (works both via bash and zsh) to track new, unwanted additions. It doesn’t automatically delete these items but provides removal commands every time I open a shell, which is frequently. Of course, you could also automatically remove them if you don’t want to manually double-check.
Notice: This script does not affect Login Items (accessible through System Preferences > Users & Groups > Login Items), where applications can be set to launch at startup and also install background daemons (often for AppStore-based Apps). Additionally, I created an alias to monitor these via the command line as well (show_background_tasks).
Enjoy!
#!/usr/bin/env bash
# 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 [ ! -s "$plist" ]; then continue; fi
if ! echo "$plist" | egrep -q "^.*Library.*/($pattern)"; then
local plist_name=$(basename "$plist" .plist)
if [[ $directory = /Library* ]]; then
echo "sudo bash -c 'launchctl disable system/$plist_name && true > \"$plist\" && chmod a-wx \"$plist\"'"
else
echo "bash -c 'launchctl disable gui/$(id -u)/$plist_name && true > \"$plist\" && chmod a-wx \"$plist\"'"
fi
fi
done
}
# Define global and local agents to manage
global_agents=(
at.obdev.littlesnitch # Little Snitch
com.docker # Docker
)
process_agents "/Library" "${global_agents[@]}"
local_agents=(
homebrew.mxcl.ollama # ollama
jp.plentycom.boa.SteerMouse # SteerMouse
)
process_agents "$HOME/Library" "${local_agents[@]}"
# vim: filetype=bash: