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

terminal-notifier hangs when not connected to UI session #276

Open
1 of 3 tasks
schinckel opened this issue Dec 19, 2019 · 3 comments
Open
1 of 3 tasks

terminal-notifier hangs when not connected to UI session #276

schinckel opened this issue Dec 19, 2019 · 3 comments

Comments

@schinckel
Copy link

Please check everything that applies to your issue:

  • I looked in closed issues and it has not already been answered
  • My issue appeared with a terminal-notifier update
  • I'm using a tool that uses terminal-notifier (guard-notifier, node-notifier...)

To help us debug your issue please include:

  • macOS version Catalina
  • terminal-notifier version 2.0.0
  • installed using homebrew

When you ssh to a Mac that does not have a current UI session (ie, I restarted my Mac before going home from work, and started an ssh session from home), you can't use terminal-notifier as part of a workflow, because it just hangs.

I'm aware that there is "no point" in having a notification, because there is nowhere to view that notification. The problem I have is that the command stops executing, rather than throwing an exception.

I could have a workflow that just ignores the status code of the command, and continues.

In my case, I have a mercurial hook that posts a notification:

update.notifier = (/usr/local/bin/terminal-notifier -title Mercurial -subtitle 'Update successful' -contentImage ~/.mercurial.png -message "Parent revisions(s): $HG_PARENT1 $HG_PARENT2")

However, if I try to chain bash commands:

hg pull upstream && hg up && hg push --rev default

This fails to execute, because it stops when attempting to post the notification: and requires a Ctrl-C to regain control of my shell.

I think it should return a suitable error code when it is unable to connect to the session, rather than just print the error and wait:

$ /usr/local/bin/terminal-notifier 
2019-12-19 16:05:54.070 terminal-notifier[9995:39570] +[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted
@schinckel
Copy link
Author

(Ultimately, it would be amazing if you could have notifications appear on my local machine when I trigger them in a script on a remote machine, but I'm guessing that's way out of scope)

@eytanbiala
Copy link

Hey, I'm running into this issue as well - have you found any workaround aside from not using terminal-notifier?

@robertpeteuil
Copy link

Not sure if this is still unsolved for folks...

In my scripts that generate notifications, I populate a variable when connected remotely, then filter on it before notification.

# set SESSION_TYPE if connected remotely
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
  SESSION_TYPE=remote/ssh
else
  case $(ps -o comm= -p "$PPID") in
    sshd|*/sshd) SESSION_TYPE=remote/ssh;;
  esac
fi

[[ -z "$SESSION_TYPE" ]] && echo "non-ssh session - trigger notification"

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