julienXX / terminal-notifier

Send User Notifications on macOS from the command-line.
Other
6.36k stars 331 forks source link

TN not working from launchd #259

Open Vartkat opened 5 years ago

Vartkat commented 5 years ago

Please check everything that applies to your issue:

To help us debug your issue please include:

in /Library/LaunchDaemons (note - StartInterval with a value of 3600 fires the script every hour)

To run the script load the plist $ sudo launchctl load PLIST_FILE To stop it unload the plist file.

Using terminal-notifier the whole script gets stuck as if it was asleep (no error). I had to kill terminal-notifier so that the bash script resume (terminal-notifier was a sub-process of the script).

I also tried replacing TN with osascript display notification but that doesn't show anything on the user screen.

I thought it was because launchd launched processes are running as root but with UserName it should run as the named user.

Notting suspicious show up in the Console.

Vartkat commented 5 years ago

I had installed terminal-notifier using brew, according to https://superuser.com/questions/734563/terminal-notifier-fails-silently-when-called-from-launchd I have to run terminal-notifier from the app bundle, so I did an alias of /usr/local/Cellar/terminal-notifier/2.0.0/terminal-notifier.app in in /Applications folder, it doesn't work better, I tried an ln -s but that neither does it run (it says too manu symlinks). If I do a ps -axw | grep term I see that terminal-notifier is stuck, I have to kill this process so that the script resumes.

julienXX commented 5 years ago

Hi @Vartkat maybe the solution described in https://github.com/julienXX/terminal-notifier/issues/148 can help.

Vartkat commented 5 years ago

The solution in #148 by @applebit924 seems a bit cryptic to me. I understand he's notifications are not fired by his main script but by a script fired by a watchdog. The watchdog runs from /Library/LaunchAgents and not from /Library/LaunchDaemons, but for the rest I don't see terminal-notifier in there unless he renamed it "Software Update Notifications" and I don't understand why he's building a notification script each time he needs to show a notification. Seems very complicated.

gregneagle commented 5 years ago

launchdaemons run as root. I would not expect root to be able to post an NSUserNotification.

Grayon commented 4 years ago

This works for me. Use 'open' command. open terminal-notifier.app --args -message "123"

Droid43 commented 4 years ago

@Vartkat A GUI can't be launched by a daemon in macOS. 'open' command can work well. open -a terminal-notifier --args -title "test"