marc walter

Show notifications from scripts in node.js

2016-01-03

So that I never forget when I need it: The module node-notifier can be used to display desktop notifications on windows_, _mac and linux with notify-osd or libnotify-bin.

Example

Straight from the official doc.

const notifier = require('node-notifier');
// String 
notifier.notify('Title', 'Message');

// Object 
notifier.notify({
  'title': 'My notification',
  'message': 'Hello, there!'
});

Another example

From file notify-sample.js adapted from the official doc.

const notifier = require('node-notifier');
const path = require('path');

let options = {
  title: 'Wake up',
  message: "It's time!",
  icon: path.join(__dirname, 'emilia.jpg'), // Absolute path (doesn't work on balloons)
  sound: true, // Only Notification Center or Windows Toasters
}

notifier.notify(options)

What the notification looks like

on win10

Windows 10 Notice

Toast can be configured to show the notification in the information center.
on win10 notification center

Additionally to the information listed in the doc

From mikaelbr/gulp-notify#90 (comment)
You can make it work by going to System > Notifications & Actions. The 'toast' app needs to have Banners enabled. (You can activate banners by clicking on the 'toast' app and setting the 'Show notification banners' to On)

Also on Windows 10 I was able to activate the entry show in information center for the app toast. That way I can see a timeline of these requests

Settings in German

first second