Files
dotfiles/scripts/install_launch_agents
2021-12-30 20:55:40 -05:00

23 lines
510 B
Bash
Executable File

#!/bin/sh
set -e
# Installs launchd agents.
agent_dir="${HOME}/Library/LaunchAgents"
uid="$(id -u "$(whoami)")"
mkdir -p "$agent_dir"
for file in "${DOTFILES}"/macOS/LaunchAgents/*.plist; do
# get just the base file name, similar to using `basename` but w/o a subshell
filename="${file##*/}"
path="${agent_dir}/${filename}"
echo "$filename"
if ! test -e "${path}"; then
echo "Installing Agent: ${filename}"
cp "${file}" "${path}"
launchctl enable "user/${uid}/${filename}"
fi
done