Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage in a bash script #148

Closed
cilia opened this issue Nov 4, 2015 · 5 comments
Closed

Usage in a bash script #148

cilia opened this issue Nov 4, 2015 · 5 comments

Comments

@cilia
Copy link

cilia commented Nov 4, 2015

I try to use terminal-notifier inside a bash script. When I call the script in a terminal manually, it works fine. However, if the script is called outside of a terminal, e.g. by launchd, then no notification appears.

Is this by design or am I missing something here?

@julienXX
Copy link
Owner

julienXX commented Nov 5, 2015

My guess is that when using launchd, you don't get access to the graphical part of the user's account and therefore can't access the Notification Center.

@applebit924
Copy link

I use a separate launch Agent to execute the terminal-notifier. That works great.

  • Jon McCullough

On Nov 5, 2015, at 11:22 AM, Julien Blanchard notifications@github.com wrote:

My guess is that when using launchd, you don't get access to the graphical part of the user's account and therefore can't access the Notification Center.


Reply to this email directly or view it on GitHub #148 (comment).

@julienXX
Copy link
Owner

julienXX commented Nov 5, 2015

@applebit924 nice, could you post your solution here?

@applebit924
Copy link

Create the LaunchAgent /Library/LaunchAgents/com.AppleBitTechnologies.coreMonitor.plist with the following contents:

Label com.AppleBitTechnologies.coreDaemon KeepAlive Program /Library/Scripts/coreDaemon/System/coreMonitor.sh WatchPaths /tmp/.coreMonitor

———————————————————————————————

Then your launch daemon can use something of this nature to get the job done:

NC_UID=$(ruby -e 'puts Time.now.to_f')

message="MESSAGE EXAMPLE"
title="TITLE EXAMPLE"
group="GROUP EXAMPLE"

echo '"'"/Library/Scripts/coreDaemon/Components/Locally-Installed/Software_Updates/Data/Applications/Software Update Notifications.app/Contents/MacOS/Software Update Notifications"'" -message "'"$message"'" -title "'"$title"'" -group "'"$group"'" ' > /tmp/.coreMonitor-NotificationCenter-$NC_UID.sh
chmod 777 /tmp/.coreMonitor-NotificationCenter-$NC_UID.sh
mv -f /tmp/.coreMonitor-NotificationCenter-$NC_UID.sh /tmp/.coreMonitor/NotificationCenter-$NC_UID.sh

———————————————————————————————

Can someone please publish this as well? I’ve been meaning to but so darn busy.

  • Jon McCullough

On Nov 5, 2015, at 11:35 AM, Julien Blanchard notifications@github.com wrote:

@applebit924 https://github.com/applebit924 nice, could you post your solution here?


Reply to this email directly or view it on GitHub #148 (comment).

@cilia
Copy link
Author

cilia commented Nov 5, 2015

Thanks for everyone's contribution. I got it working by specifying the full path of terminal-notifier (installed via homebrew). In contrast with calling the script in the terminal, I guess launchd has no idea of where to find terminal-notifier without any guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants