-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·38 lines (30 loc) · 866 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
PROJECT=logind
IDENTIFIER=com.doggles.$PROJECT
# Commands to be run when user logs in
loginItems()
{
echo "Replace these commands with"
echo "ones you want to run at user"
echo "login. These commands will"
echo "run as root, so you do not"
echo "need to use 'sudo'"
}
## -- END CONFIGURATION -- ##
# Function returns true if Finder pid is running
userLoggedIn()
{
pgrep Finder && return 0 || return 1
}
# Unloads Launch Daemon and remove plist and script
cleanup()
{
launchctl remove -F /Library/LaunchDaemons/${IDENTIFIER:?}.plist
rm -f /Library/LaunchDaemons/${IDENTIFIER:?}.plist
rm -rf /usr/local/${PROJECT:?}
}
if userLoggedIn && [[ ! $(stat -f %Su /dev/console) = "_mbsetupuser" ]]; then
loginItems # Execute run-at-login workflow
trap 'cleanup' EXIT # Remove Launch Daemon on script exit
fi
exit