Sending Notifications to a specified user from a launchctrl daemon
0
votes
1
answer
62
views
I have created a daemon that runs at system startup, and has root privileges; call it a 'system daemon'. I have created this daemon using [the
LaunchControl
app](https://soma-zone.com/LaunchControl/) . This daemon runs a bash
script once per day that monitors an off-site resource, and I would like to have it send a Notification to my "regular user" account on my Mac.
Here is a simplified version of the script:
#!/opt/local/bin/bash
PATH=/opt/local/libexec/gnubin:/opt/local/bin:$PATH
osascript -e 'display notification "** This is only a test **" with title "NOTICE of Notification"'
touch /Users/seamus/Desktop/NOTICEOFNOTHING.TXT
I added the touch
command to verify the daemon & script are actually working. I do see the file created on my Desktop, but I get ***no Notification***.
I've done some research using the term *'macos osascript post "notification" to specified user'*, and related terms - but I am not turning up anything useful. I don't actually know that it is possible to do this as I'm attempting to do it, but it certainly seems like a reasonable use of the Notifications facility!
I suppose I could create a "User Agent" in LaunchControl to check for the presence of the file created by the "system daemon", but that seems such a kludge for a modern OS.
Also - it's been suggested elsewhere that posting a Notification to a user from a system daemon
is *somehow* a "security issue"?! But it is unclear how posting a user Notification can be a security issue when the root
user can log a regular user off - or even render the entire system unusable.
And so my question: Can someone tell me how to issue a notification to a regular user from a "system daemon"?
Asked by Seamus
(5329 rep)
Apr 21, 2025, 05:10 AM
Last activity: Apr 23, 2025, 07:40 AM
Last activity: Apr 23, 2025, 07:40 AM