julienXX / terminal-notifier

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

NSNotificationCenter connection invalid #220

Closed luchofariello closed 7 years ago

luchofariello commented 7 years ago

@julienXX hi julien,

I run a process from launchctl (LaunchDaemon) and it gives me error: 2017-05-22 15: 16: 48.109 terminal-notifier [35828: 581946] NSNotificationCenter connection invalid 2017-05-22 15: 16: 48.109 terminal-notifier [35828: 581946] Connection to notification center invalid. ServerConnectionFailure: 1 invalidated: 0

I am executing it like this: /Users/user/terminal-notifier -title "title" -subtitle "subtitle" -message "message" -actions "actions1","actions2" -dropdownLabel "dropdownLabel" -appIcon pathalert.icns -sound "frog" -timeout 120

If I run it directly manual it works correctly.

mac-version: 10.12.3 terminal-notifier-version: 1.8.0

Thank you very much, I hope to answer.

julienXX commented 7 years ago

Hello @luchofariello it looks like your script is ran using an account without access to the NSNotificationCenter. Maybe answers to this issue can help https://github.com/julienXX/terminal-notifier/issues/145#issuecomment-166856810 ?

rr0ss0rr commented 7 years ago

Yup .. Make sure you are running it as you and to keep it simple, have it run a script that you own. I do this myself. If you need it to run through sudo, just modify /etc/sudoers (visudo) to authorize your userid (via the admin group per below) to run the commands that you need. ie

%admin ALL=(ALL) ALL, NOPASSWD: /sbin/mount, /sbin/umount, ...

luchofariello commented 7 years ago

Hi

Tried again but I had the same error, run it as /Library/LauchAgents and I already have the line in the sudoers.

User ALL = (ALL) ALL, NOPASSWD: ALL

If I run it with sudo -u user terminal-notifier I have the same error but only if I run it with lauchctl. Being sudo and running the command manually with sudo -u user works correctly. I also tried to execute LauchDaemon with the key username but I have the same error.

do you have any other ideas?

Thank you for your help.

luchofariello commented 7 years ago

sorry, sudoer line

user ALL=(ALL) NOPASSWD: ALL

rr0ss0rr commented 7 years ago

I would move the command to a script owned by user and have launchctl run the script.

Your example /Users/user/terminal-notifier -title "title" -subtitle "subtitle" -message "message" -actions "actions1","actions2" -dropdownLabel "dropdownLabel" -appIcon pathalert.icns -sound "frog" -timeout 120

Where are your actions defined? You mentioned sudo, but your command doesn't reflect the command. Is terminal-notifier located in your parent directory? Also, I would not run terminal-notifier as an alert or wait for a response in launchctl without having the command be run as a background process (& at the end)

shannonpasto commented 7 years ago

Perhaps you should try running it as a Launch Agent?

~/Library/LaunchAgents Per-user agents provided by the user. /Library/LaunchAgents Per-user agents provided by the administrator /Library/LaunchDaemons System-wide daemons provided by the administrator

Shannon

On 23 May 2017 at 04:33, luchofariello notifications@github.com wrote:

@julienXX https://github.com/julienxx hi julien,

I run a process from launchctl (LaunchDaemon) and it gives me error: 2017-05-22 15: 16: 48.109 terminal-notifier [35828: 581946] NSNotificationCenter connection invalid 2017-05-22 15: 16: 48.109 terminal-notifier [35828: 581946] Connection to notification center invalid. ServerConnectionFailure: 1 invalidated: 0

I am executing it like this: /Users/user/terminal-notifier -title "title" -subtitle "subtitle" -message "message" -actions "actions1","actions2" -dropdownLabel "dropdownLabel" -appIcon pathalert.icns -sound "frog" -timeout 120

If I run it directly manual it works correctly.

mac-version: 10.12.3 terminal-notifier-version: 1.8.0

Thank you very much, I hope to answer.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/julienXX/terminal-notifier/issues/220, or mute the thread https://github.com/notifications/unsubscribe-auth/AYPvHINhDoCr9Et-4D2xX8n4CWujmvfNks5r8dT0gaJpZM4NiuW- .

-- Mr Shannon Pasto SOE Engineer (OS X)

Monash University eSolutions - Device Solutions 700 Blackburn Rd Notting Hill VIC 3168

T: +61 (0)3 990 32914 E: shannon.pasto@monash.edu W: monash.edu http://www.monash.edu/

Twitter/MonasheSol https://twitter.com/intent/user?screen_name=monashesol eSolutions Live – Self Help Central https://sites.google.com/a/monash.edu/esolutions/

adkron commented 7 years ago

I have the same issue, but only if I'm running in tmux. Are you using tmux?

foice commented 7 years ago

Same here, the problem shows up only in tmux ... any fix for this?

stein189 commented 7 years ago

Same problem when using tmux

Darmody commented 7 years ago

tmux issue +1

hemanth-avs commented 7 years ago

I see error when using Tmux

julienXX commented 7 years ago

Still not using tmux so I won't be able to help here. Please refer to the previous tmux issues, closing this one for now.