tj / node-growl

growl unobtrusive notification system for nodejs
481 stars 64 forks source link

Add 'exec' option for custom notifiers #45

Closed sukima closed 10 years ago

sukima commented 10 years ago

Pass in an 'exec' option to growl() to use a custom command for notifications. It will append the message to the command unless you include a %s in the command string which is expanded to the message. 'title' is expanded to a Title: prefix in the quoted message.

Also %%s will NOT expand but %s will (so it can be escaped if needed.

The hack isn't as clean as I'd like but it's kinda the way the original data structure was designed. Perhaps this one commit could segway to a more expressive API then it is at the moment.

To address issue #41 one could use this like so:

growl('test message', { exec: 'tmux display-message' });
jbnicolai commented 10 years ago

Running node test.js I do not see the expected stdout output from the exec tests.

Changing them to, e.g., echo %s > out.txt and mkdir, did allow me to verify it works as intended both with substitution and concatenation. Any idea why I'm not seeing the output from the echo in my terminal?

Other than that: :+1:

Care to update the documentation as well?

sukima commented 10 years ago

I'm guessing it's some interaction between node's stdout and the sub-shell's stdout. Think I've run into that before in node. I'll look into it. An I'll look into documentation as another PR.