How can I write to Notification Center from a launchd command?
You can send to Notification Centre using Applescript (osascript )in you shell script.
There is a very good thread here that explains the various ways of either running only Applescript as a shell script or being able to mix applescript in with bash, for example.
I created a shell script with:
#!/bin/bash
theDate=`date '+DATE: %m/%d/%y TIME:%H:%M:%S'`
osascript -e "display notification \"$theDate\" with title \"test 1\" subtitle \" sub 1\""
I then created a LaunchDaemon in the same way you have and loaded it without sudo.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>notifTest</string>
<key>ProgramArguments</key>
<array>
<string>/Users/userName/Documents/notify.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>90</integer>
</dict>
</plist>
Every 90 seconds I get a notification:
The notification icon you will notice is the Script Editors one. Which means the Notification is controlled by the Script Editors Notification settings in Notification Centre