Socket
Socket
Sign inDemoInstall

node-notifier

Package Overview
Dependencies
1
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-notifier

A Node.js wrapper for the terminal-notifier application


Version published
Weekly downloads
5.2M
decreased by-0.76%
Maintainers
1
Install size
444 kB
Created
Weekly downloads
 

Package description

What is node-notifier?

The node-notifier package is a Node.js module for sending native notifications on different platforms like Windows, Mac, and Linux. It provides an easy-to-use API to show system notifications using the native notification system of the operating system.

What are node-notifier's main functionalities?

Cross-platform notifications

This feature allows you to send desktop notifications across different operating systems. The code sample shows how to send a simple notification with a title and a message.

const notifier = require('node-notifier');
notifier.notify({
  title: 'My notification',
  message: 'Hello, this is a notification!'
});

Notification actions

This feature allows you to listen for user interactions with the notification, such as clicking on it. The code sample demonstrates how to handle a click event on the notification.

const notifier = require('node-notifier');
notifier.notify({
  title: 'My notification',
  message: 'Click to perform an action',
  wait: true
}, (err, response, metadata) => {
  if (metadata.activationType === 'clicked') {
    console.log('Notification clicked!');
  }
});

Custom notification sound

This feature allows you to customize the notification sound and appearance. The code sample shows how to send a notification with a custom sound and icon.

const notifier = require('node-notifier');
notifier.notify({
  title: 'My notification',
  message: 'With a custom sound!',
  sound: true, // Only Notification Center or Windows Toasters
  appIcon: '/path/to/icon.png', // Absolute path (doesn't work on balloons)
  contentImage: '/path/to/image.png' // Absolute Path to Attached Image (Content Image)
});

Other packages similar to node-notifier

Readme

Source

node-notifier

A Node.js wrapper for the terminal-notifier application by Eloy Durán.

Requirements

  • Mac OS X (>= 10.8) or Linux with the notify-send module.

If using Linux, notify-send must be installed on your system. However, terminal-notifier, comes bundled in the module. So on Mac, not additional installations is necessary.

Install

$ npm install node-notifier

Usage

Same usage and parameter setup as terminal-notifier.

Example

Where terminal-notifier say to use the -message option, you can do this in node-notifier

var notifier = require('node-notifier');

notifier.notify({
	message: 'Hello World'
});

You can specify the second argument as a callback for getting error and response.

var notifier = require('node-notifier');

notifier.notify({
	title: 'My application',
	message: 'New notification'
}, function(error, response) {
	console.log(response);
});

The response will be given as an object. E.g., when running notifier.notify({list: "ALL"}), this could be the response:

{ response:
   [ { GroupID: null,
       Title: 'Terminal',
       Subtitle: null,
       Message: 'Another message',
       'Delivered At': Wed Dec 12 2012 15:23:38 GMT+0100 (CET) },
     { GroupID: null,
       Title: 'Terminal',
       Subtitle: null,
       Message: 'Another message',
       'Delivered At': Wed Dec 12 2012 15:23:31 GMT+0100 (CET) },
     { GroupID: 2,
       Title: 'Terminal',
       Subtitle: null,
       Message: 'Testing',
       'Delivered At': Wed Dec 12 2012 15:22:41 GMT+0100 (CET) },
     { GroupID: 1,
       Title: 'Terminal',
       Subtitle: null,
       Message: 'Testing',
       'Delivered At': Wed Dec 12 2012 15:22:29 GMT+0100 (CET) } ],
  type: 'list' }

There are three different types:

  • deliviered when a message is delivered.
  • removed when all or one message is removed. If all messages are removed, the response property will have several elements.
  • list when a list is presented. Even when doing list: 1.

Module TODO

  1. Be robust and have unit tests.

When these criterias are met, the module will be versioned 1.0.

NB: Previous plans of supporting both growlnotify and terminal-notifier, are abandoned. This module will only do terminal-notifier.

Keywords

FAQs

Last updated on 16 Feb 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc