mikaelbr / node-notifier

A Node.js module for sending notifications on native Mac, Windows and Linux (or Growl as fallback)
MIT License
5.72k stars 323 forks source link

Tmux notifier #136

Open riesinger opened 7 years ago

riesinger commented 7 years ago

I think it would be awesome to have a notifier sending the notifications to tmux. I know that there is a command called tmux display-message, which can show messages above the status bar.

I would really appreciate that feature.

kurisubrooks commented 7 years ago

tmux might be possible under linux, but it's currently not possible under macOS.

riesinger commented 7 years ago

Just like notify-send is not available on OSX or Windows.... I do not see how this should be an issue?

kurisubrooks commented 7 years ago

I was referring to this; https://github.com/mikaelbr/node-notifier#use-inside-tmux-session

riesinger commented 7 years ago

Thanks, but I don't see how this is related? I don't want to send notifications from tmux, but to tmux. Sorry if I'm not understanding 😅

kurisubrooks commented 7 years ago

oh.... sorry i misunderstood. is that even possible? does tmux have it's own notifications system we could hook in to?

kurisubrooks commented 7 years ago

Just found a related issue in another one of mikael's repos; https://github.com/mikaelbr/gulp-notify/issues/102. We should probably look into this? @mikaelbr

mikaelbr commented 7 years ago

This might make sense. For instance, if there are some that don't use X (with notify-send installed) and want to display messages.

What we need for this to work is:

  1. A way to detect if user is in tmux session
  2. A precedence order for notifications. If notify-send is installed on the system, should it be used? What about Growl? Is it tmux > notify-send > growl or is that a matter of taste? Depending on precedence order this could break current behaviour and we need to "step carefully".
  3. Implement a new notifier, which will be a simple one. It doesn't require any external vendor and the options seems to be few. From what I can find: https://gist.github.com/JarrodCTaylor/6325263
riesinger commented 7 years ago

That is exactly my use case.

  1. That should be pretty easy, I guess. For starters, check the $TERM variable. It should either contain "tmux..." or "screen..."
  2. No idea how to tackle this.... I guess you could just let the user choose his to which notifier to use...
  3. I looked into it, maybe I can help with this one.
mikaelbr commented 7 years ago

In regards to (2.), one of the philosophies behind node-notifier is to work seamlessly on all platforms. One way it does that is to have a designed precedence of what notifiers to use (see decision flow) in addition to being able to specify and override what notifier to use.

I suggest having the precedence order: notify-send > growl > tmux message. This is as both notify-send and growl supports more rich messages. Also I think we maybe will have issues with https://github.com/mikaelbr/node-notifier#use-inside-tmux-session if we do it the other way around.

Feel very much free to look into this and open a PR. Contributions are very welcome

mikaelbr commented 7 years ago

I think it makes sense for someone who uses tmux to implement this.