public
Created

An example of what you might do with the conditional shown in https://gist.github.com/tjluoma/4970335

  • Download Gist
islaunchd2.sh
Shell
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
#!/bin/zsh -f
 
NAME="$0:t"
 
PPID_NAME=$(/bin/ps -p $PPID | fgrep '/sbin/launchd' | awk '{print $NF}')
 
if [ "$PPID_NAME" = "/sbin/launchd" ]
then
# This IS launchd, so send the message via growlnotify so it will be seen
msg () {
growlnotify --message "$@" "$NAME"
}
 
else
# This is NOT via launchd, so send the message to stdout via 'echo'
 
msg () {
echo "$NAME: $@"
}
fi
 
msg "Hello World"
 
exit 0
#EOF

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.