osx-notifier

2019-07-13 admin

osx-notifier是什么

什么是osx-notifier,Send notifications to the OS X Notification Center using terminal-notifier.app

osx-notifier使用教程帮助文档

osx-notifier

Reduction of node-osx-notifier to drive from the command line or directly from another node.js script, instead of an express server.

Command line install & usage

npm install -g osx-notifier

Usage (osx-notifier --help):

osx-notifier
  --type      type of icon to show;
              one of "info", "fail", or "pass" [default: "info"]

  --title     title of the notification [default: "Terminal"]
  --subtitle  subtitle of the notification
  --message   message body of the notification [required]

  --group     replace and be replaced by any notifications of the same group

  --remove    remove any notifications previously posted with this group
              (or ALL groups)

  --list      list notifications previously posted with this group
              (or ALL groups)

  --activate  bundle identifier of an application to be activated
              if the user clicks the notification

  --open      open a url / file / custom url scheme
              if the user clicks the notification

  --execute   execute a shell command
              if the user clicks the notification

  --help      print this help message
  --verbose   print extra output
  --version   print version

API install & usage

npm install osx-notifier

Or in your package.json:

{
  "dependencies": {
    "osx-notifier": "*"
  }
}

Usage:

var notify = require('osx-notifier');

var duration = 45;
notify({
  type: 'pass',
  title: 'Taskdoer Report',
  subtitle: 'Task completed',
  message: 'Took ' + duration + ' seconds.',
  group: 'taskdoer',
});

–type

The Mac OS X Notification Center can only be accessed via signed apps, and any message sent from an application must be accompanied by the icon for that application.

Three variations on terminal-notifier are included with this app, which are accessed via the different --type options:

--type sample
info info screenshot
pass pass screenshot
fail fail screenshot

Winston integration

You can use this functionality from within winston (a popular logging library) as a “Transport” via my winston-notification-center plugin package (available from npm).

Example:

var winston = require('winston');
var NotificationCenterTransport = require('winston-notification-center');
winston.add(NotificationCenterTransport);
winston.info('Hello world.');

See the winston-notification-center project page for more options.

Credits

Thanks to azoff for the prebuilt apps and the screenshots, and to alloy for the great OS X application wrapper.

License

Copyright 2013 Christopher Brown. MIT Licensed.

你可能感兴趣的文章:

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-69655.html

文章标题:osx-notifier

回到顶部