npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

desknotifier

v1.0.6

Published

Cross-platform desktop notifications for Node.js as API and CLI.

Downloads

9

Readme

Desknotify

Desktop notifications for Node.js as both: API and CLI (command-line interface).

For Windows, Mac and obviously Linux.

1. Introduction

Basically, the purpose of this library is to provide a simple API and CLI for node-notifier, which already does in fact. So, this is a wrapper, and nothing genuine is found here.

2. Installation

To install the Desknotify module, you can just:

~$ npm install desknotify

If you want to use Desknotify from your command line easily, you can install it globally like:

~$ npm install -g desknotify

This way, you will be able to call Desknotify from your console.

3. Examples

Overview

Example 1

Sending a simple desktop notification from a Node.js program:

require("desknotify").notify({
  title: "Some title",
  message: "Some message"
});
Example 2

Sending the same notification from the command line:

~$ desknotify -t "Some title" -m "Some message"

API examples

Example 1

The simplest example possible would be:

require("desknotify").notify();

It should show a notification with the default title, message and icon.

Example 2

The most complex example possible would be:

require("../src/desknotify.js").notify({
  title: "Remember",
  message: "This is only a wrapper!! node-notify (and other OPEN SOURCE software) is doing the hard work under the hood.",
  icon: "/path/to/icon.png"
}).then(function() {
  console.log("Notification process successful.");
}).catch(function(error) {
  console.log("Notification process with errors.");
}).finally(function() {
  console.log("Notification process finished.");
});

In this case, the notification will show the title and message specified, and the image of the icon will be taken from the specified path. Moreover, we are using the returned Promise (by the notify method) to provide a callback for successful notifications, for failed notifications, and for every notification once it is closed.

CLI examples

Example 1

The simplest example possible would be:

~$ desknotify

But it will show the default notification (default title, message and icon).

Example 2

Some more complex examples would be:

~$ desknotify --title "Title of notification" --message "Message of notification" --icon "/path/to/icon.png"

Or abbreviated:

~$ desknotify -t "Title of notification" -m "Message of notification" -i "/path/to/icon.png"

4. Reference

API Reference


Desknotify = require("desknotify"); // {Object}

This object holds all the Desknotify API. It is what you get when you import the NPM module.


Desknotify.notify(...) // {Function}

This is the notifier function of the API. It is the responsible of sending the desktop notifications.


Desknotify.notify(Object:details) // {Object:Promise}

This function should send a notification to the operative system, and the user should see it.

The available parameters are the details, an {Object} with some (or none) of the next properties:

title: {String} the title of the notification.

message: {String} the message of the notification.

icon: {String} the path of the icon of the notification.

The notify function, when it is called, it will return a Promise object. This means that we can chain these methods, passing one callback to each of them:

then: for successfull notifications.

catch: for failed notifications.

finally: for all notifications.


CLI Reference

These are the parameters available for the CLI tool:

  1. --title or -t: text with the title of the notification.

  2. --message or -m: text with the message of the notification.

  3. --icon or -i: text with the path of the icon of the notification.

To test it, you can:

~$ desknotify -t "Title" -m "Message"

Or even this would work as well:

~$ desknotify

5. Conclusion

Desknotify is only a wrapper of various (lots, in fact) (nested) pieces of software.

6. Thanks

Thanks to all the developers that have contributed somehow for this module to be possible.