├── .npmignore ├── .gitignore ├── osx ├── terminal-notifier-fail.app │ └── Contents │ │ ├── PkgInfo │ │ ├── Resources │ │ ├── Failed.icns │ │ └── en.lproj │ │ │ ├── MainMenu.nib │ │ │ ├── InfoPlist.strings │ │ │ └── Credits.rtf │ │ ├── MacOS │ │ └── terminal-notifier │ │ ├── _CodeSignature │ │ └── CodeResources │ │ └── Info.plist ├── terminal-notifier-info.app │ └── Contents │ │ ├── PkgInfo │ │ ├── Resources │ │ ├── Notify.icns │ │ └── en.lproj │ │ │ ├── MainMenu.nib │ │ │ ├── InfoPlist.strings │ │ │ └── Credits.rtf │ │ ├── MacOS │ │ └── terminal-notifier │ │ ├── _CodeSignature │ │ └── CodeResources │ │ └── Info.plist └── terminal-notifier-pass.app │ └── Contents │ ├── PkgInfo │ ├── Resources │ ├── Success.icns │ └── en.lproj │ │ ├── MainMenu.nib │ │ ├── InfoPlist.strings │ │ └── Credits.rtf │ ├── MacOS │ └── terminal-notifier │ ├── _CodeSignature │ └── CodeResources │ └── Info.plist ├── package.json ├── LICENSE-MIT ├── lib └── node-osx-notifier.js └── README.md /.npmignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .idea 3 | .DS_Store -------------------------------------------------------------------------------- /osx/terminal-notifier-fail.app/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPL???? -------------------------------------------------------------------------------- /osx/terminal-notifier-info.app/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPL???? -------------------------------------------------------------------------------- /osx/terminal-notifier-pass.app/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPL???? -------------------------------------------------------------------------------- /osx/terminal-notifier-fail.app/Contents/Resources/Failed.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-fail.app/Contents/Resources/Failed.icns -------------------------------------------------------------------------------- /osx/terminal-notifier-info.app/Contents/Resources/Notify.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-info.app/Contents/Resources/Notify.icns -------------------------------------------------------------------------------- /osx/terminal-notifier-pass.app/Contents/Resources/Success.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-pass.app/Contents/Resources/Success.icns -------------------------------------------------------------------------------- /osx/terminal-notifier-fail.app/Contents/MacOS/terminal-notifier: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-fail.app/Contents/MacOS/terminal-notifier -------------------------------------------------------------------------------- /osx/terminal-notifier-info.app/Contents/MacOS/terminal-notifier: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-info.app/Contents/MacOS/terminal-notifier -------------------------------------------------------------------------------- /osx/terminal-notifier-pass.app/Contents/MacOS/terminal-notifier: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-pass.app/Contents/MacOS/terminal-notifier -------------------------------------------------------------------------------- /osx/terminal-notifier-fail.app/Contents/Resources/en.lproj/MainMenu.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-fail.app/Contents/Resources/en.lproj/MainMenu.nib -------------------------------------------------------------------------------- /osx/terminal-notifier-info.app/Contents/Resources/en.lproj/MainMenu.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-info.app/Contents/Resources/en.lproj/MainMenu.nib -------------------------------------------------------------------------------- /osx/terminal-notifier-pass.app/Contents/Resources/en.lproj/MainMenu.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-pass.app/Contents/Resources/en.lproj/MainMenu.nib -------------------------------------------------------------------------------- /osx/terminal-notifier-fail.app/Contents/Resources/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-fail.app/Contents/Resources/en.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /osx/terminal-notifier-info.app/Contents/Resources/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-info.app/Contents/Resources/en.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /osx/terminal-notifier-pass.app/Contents/Resources/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azoff/node-osx-notifier/HEAD/osx/terminal-notifier-pass.app/Contents/Resources/en.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /osx/terminal-notifier-fail.app/Contents/Resources/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /osx/terminal-notifier-info.app/Contents/Resources/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /osx/terminal-notifier-pass.app/Contents/Resources/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"node-osx-notifier", 3 | "description":"A NodeJS Server for sending notifications to OSX Mountain Lion's Notification Center", 4 | "version":"0.1.0", 5 | "homepage":"https://github.com/azoff/node-osx-notifier", 6 | "author":{ 7 | "name":"Jonathan Azoff", 8 | "email":"jon@azoffdesign.com", 9 | "url":"http://azoffdesign.com" 10 | }, 11 | "dependencies": { 12 | "express": "3.0.x" 13 | }, 14 | "repository":{ 15 | "type":"git", 16 | "url":"git://git@github.com:azoff/node-osx-notifier.git" 17 | }, 18 | "bugs":{ 19 | "url":"https://github.com/azoff/node-osx-notifier/issues" 20 | }, 21 | "licenses":[ 22 | { 23 | "type":"MIT", 24 | "url":"https://github.com/azoff/node-osx-notifier/blob/master/LICENSE-MIT" 25 | } 26 | ], 27 | "main":"lib/node-osx-notifier", 28 | "engines":{ 29 | "node":">= 0.8.0" 30 | }, 31 | "bin":{ 32 | "node-osx-notifier":"lib/node-osx-notifier.js" 33 | }, 34 | "keywords":["osx"] 35 | } -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Jonathan Azoff 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /osx/terminal-notifier-fail.app/Contents/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Resources/Failed.icns 8 | 9 | 5PTHyCZ2DVpqH9uT1YhHCjnGTLM= 10 | 11 | Resources/en.lproj/Credits.rtf 12 | 13 | hash 14 | 15 | YKJIFIsxneJuNkJNJQIcJIjiPOg= 16 | 17 | optional 18 | 19 | 20 | Resources/en.lproj/InfoPlist.strings 21 | 22 | hash 23 | 24 | MiLKDDnrUKr4EmuvhS5VQwxHGK8= 25 | 26 | optional 27 | 28 | 29 | Resources/en.lproj/MainMenu.nib 30 | 31 | hash 32 | 33 | N1QqAM17vgDk7XNtv27koaE4IhE= 34 | 35 | optional 36 | 37 | 38 | 39 | rules 40 | 41 | ^Resources/ 42 | 43 | ^Resources/.*\.lproj/ 44 | 45 | optional 46 | 47 | weight 48 | 1000 49 | 50 | ^Resources/.*\.lproj/locversion.plist$ 51 | 52 | omit 53 | 54 | weight 55 | 1100 56 | 57 | ^version.plist$ 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /osx/terminal-notifier-info.app/Contents/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Resources/Notify.icns 8 | 9 | KcJRIuj13j1C56RrHQi7g7sxcr8= 10 | 11 | Resources/en.lproj/Credits.rtf 12 | 13 | hash 14 | 15 | YKJIFIsxneJuNkJNJQIcJIjiPOg= 16 | 17 | optional 18 | 19 | 20 | Resources/en.lproj/InfoPlist.strings 21 | 22 | hash 23 | 24 | MiLKDDnrUKr4EmuvhS5VQwxHGK8= 25 | 26 | optional 27 | 28 | 29 | Resources/en.lproj/MainMenu.nib 30 | 31 | hash 32 | 33 | N1QqAM17vgDk7XNtv27koaE4IhE= 34 | 35 | optional 36 | 37 | 38 | 39 | rules 40 | 41 | ^Resources/ 42 | 43 | ^Resources/.*\.lproj/ 44 | 45 | optional 46 | 47 | weight 48 | 1000 49 | 50 | ^Resources/.*\.lproj/locversion.plist$ 51 | 52 | omit 53 | 54 | weight 55 | 1100 56 | 57 | ^version.plist$ 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /osx/terminal-notifier-pass.app/Contents/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Resources/Success.icns 8 | 9 | 78sPBudKpASNEPzsDGG9KML1+uw= 10 | 11 | Resources/en.lproj/Credits.rtf 12 | 13 | hash 14 | 15 | YKJIFIsxneJuNkJNJQIcJIjiPOg= 16 | 17 | optional 18 | 19 | 20 | Resources/en.lproj/InfoPlist.strings 21 | 22 | hash 23 | 24 | MiLKDDnrUKr4EmuvhS5VQwxHGK8= 25 | 26 | optional 27 | 28 | 29 | Resources/en.lproj/MainMenu.nib 30 | 31 | hash 32 | 33 | N1QqAM17vgDk7XNtv27koaE4IhE= 34 | 35 | optional 36 | 37 | 38 | 39 | rules 40 | 41 | ^Resources/ 42 | 43 | ^Resources/.*\.lproj/ 44 | 45 | optional 46 | 47 | weight 48 | 1000 49 | 50 | ^Resources/.*\.lproj/locversion.plist$ 51 | 52 | omit 53 | 54 | weight 55 | 1100 56 | 57 | ^version.plist$ 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /osx/terminal-notifier-fail.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 12A269 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | terminal-notifier 11 | CFBundleIconFile 12 | Failed 13 | CFBundleIdentifier 14 | nl.superalloy.oss.failed.terminal-notifier 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | terminal-notifier 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.5.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 7 27 | DTCompiler 28 | 29 | DTPlatformBuild 30 | 4F1003 31 | DTPlatformVersion 32 | GM 33 | DTSDKBuild 34 | 12A264 35 | DTSDKName 36 | macosx10.8 37 | DTXcode 38 | 0441 39 | DTXcodeBuild 40 | 4F1003 41 | LSMinimumSystemVersion 42 | 10.8 43 | LSUIElement 44 | 45 | NSHumanReadableCopyright 46 | Copyright © 2012 Eloy Durán. All rights reserved. 47 | NSMainNibFile 48 | MainMenu 49 | NSPrincipalClass 50 | NSApplication 51 | 52 | 53 | -------------------------------------------------------------------------------- /osx/terminal-notifier-info.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 12A269 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | terminal-notifier 11 | CFBundleIconFile 12 | Notify 13 | CFBundleIdentifier 14 | nl.superalloy.oss.notify.terminal-notifier 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | terminal-notifier 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.5.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 7 27 | DTCompiler 28 | 29 | DTPlatformBuild 30 | 4F1003 31 | DTPlatformVersion 32 | GM 33 | DTSDKBuild 34 | 12A264 35 | DTSDKName 36 | macosx10.8 37 | DTXcode 38 | 0441 39 | DTXcodeBuild 40 | 4F1003 41 | LSMinimumSystemVersion 42 | 10.8 43 | LSUIElement 44 | 45 | NSHumanReadableCopyright 46 | Copyright © 2012 Eloy Durán. All rights reserved. 47 | NSMainNibFile 48 | MainMenu 49 | NSPrincipalClass 50 | NSApplication 51 | 52 | 53 | -------------------------------------------------------------------------------- /osx/terminal-notifier-pass.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 12A269 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | terminal-notifier 11 | CFBundleIconFile 12 | Success 13 | CFBundleIdentifier 14 | nl.superalloy.oss.success.terminal-notifier 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | terminal-notifier 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.5.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 7 27 | DTCompiler 28 | 29 | DTPlatformBuild 30 | 4F1003 31 | DTPlatformVersion 32 | GM 33 | DTSDKBuild 34 | 12A264 35 | DTSDKName 36 | macosx10.8 37 | DTXcode 38 | 0441 39 | DTXcodeBuild 40 | 4F1003 41 | LSMinimumSystemVersion 42 | 10.8 43 | LSUIElement 44 | 45 | NSHumanReadableCopyright 46 | Copyright © 2012 Eloy Durán. All rights reserved. 47 | NSMainNibFile 48 | MainMenu 49 | NSPrincipalClass 50 | NSApplication 51 | 52 | 53 | -------------------------------------------------------------------------------- /lib/node-osx-notifier.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | var path = require('path'); 4 | var express = require('express'); 5 | var exec = require('child_process').execFile; 6 | 7 | var port = process.argv.length > 2 ? process.argv[2] : 1337; 8 | var hostname = process.argv.length > 3 ? process.argv[3] : 'localhost'; 9 | var server = express(); 10 | 11 | var root = path.dirname(__dirname); 12 | var binary = path.join(root, 'osx/terminal-notifier-{type}.app/Contents/MacOS/terminal-notifier'); 13 | 14 | function command(req, res, next) { 15 | req.data = req[this]; 16 | req.file = binary.replace('{type}', req.params.type); 17 | req.args = []; 18 | Object.keys(req.data).forEach(function(arg){ 19 | req.args.push('-' + arg); 20 | req.args.push(req.data[arg]); 21 | }); 22 | next(); 23 | } 24 | 25 | function execute(file, args, callback) { 26 | exec(file, args, function(error, stdout){ 27 | stdout = stdout ? stdout.trim().split('\n') : null; 28 | if (error) { 29 | error.error = stdout || 'invalid type.'; 30 | callback(error); 31 | } else { 32 | callback(null, stdout || ['done.']); 33 | } 34 | }); 35 | } 36 | 37 | function list(rows) { 38 | var notifications = [] 39 | ; 40 | var headers = rows.shift().toLowerCase() 41 | .replace(' ', '_').replace('id', '_id').split('\t'); 42 | rows.forEach(function(row){ 43 | var cols = row.split('\t'); 44 | var result = {}; 45 | cols.forEach(function(col, i){ 46 | result[headers[i]] = col === '(null)' ? null : col; 47 | }); 48 | notifications.push(result); 49 | }); 50 | return { notifications: notifications }; 51 | } 52 | 53 | function route(req, res) { 54 | console.log.apply(console, ['>'].concat(req.args)); 55 | execute(req.file, req.args, function(error, input){ 56 | if (error) { 57 | res.json(error); 58 | } else if(req.data.list) { 59 | res.json(list(input)); 60 | } else { 61 | res.json({status:input[0]}); 62 | } 63 | }); 64 | } 65 | 66 | if(!module.parent) { 67 | // setup routes 68 | server.use(express.bodyParser()); 69 | server.get('/:type', command.bind('query'), route); 70 | server.post('/:type', command.bind('body'), route); 71 | 72 | // start server 73 | console.info('starting server...'); 74 | server.listen(port, hostname, function(){ 75 | console.info('server started:', 'http://'+hostname+':'+port); 76 | }); 77 | } else { 78 | module.exports = { 79 | call: function(type, args, cb) { 80 | console.info.apply(console, ['Notifying >'].concat([type], args)); 81 | 82 | var file = binary.replace('{type}', type); 83 | var method_args = []; 84 | Object.keys(args).forEach(function(arg){ 85 | method_args.push('-' + arg); 86 | method_args.push(args[arg]); 87 | }); 88 | 89 | execute(file, method_args, cb); 90 | } 91 | }; 92 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | node-osx-notifier 2 | =========================== 3 | A [NodeJS](http://nodejs.org) Server for sending notifications to OSX Mountain Lion's 4 | [Notification Center](http://www.macworld.com/article/1165411/mountain_lion_hands_on_with_notification_center.html). 5 | 6 | Synopsis 7 | -------- 8 | OSX Mountain Lion comes packaged with a built-in notification center. For whatever reason, [Apple sandboxed the 9 | notification center API](http://forums.macrumors.com/showthread.php?t=1403807) to apps hosted in its App Store. The end 10 | result? A potentially useful API shackled to Apple's ecosystem. 11 | 12 | Thankfully, [Eloy Durán](https://github.com/alloy) put together a 13 | [set of sweet osx apps](https://github.com/alloy/terminal-notifier) that allow terminal access to the sandboxed API. 14 | **node-osx-notifier** wraps these apps with a simple [express](https://github.com/visionmedia/express) server, exposing 15 | an HTTP interface to the closed API. 16 | 17 | It's not perfect, and the implementor will quickly notice its limitations. However, it's a start and any pull requests 18 | are accepted and encouraged! 19 | 20 | Installation 21 | ------------ 22 | The following command will install the notification server. Use `-g` to install the server as a global binary. 23 | 24 | ```sh 25 | [sudo] npm install [-g] node-osx-notifier 26 | ``` 27 | 28 | Running The Server 29 | ------------------ 30 | Running the server is easy peasy. If you installed the server globally, then starting the server is as easy as: 31 | 32 | ```sh 33 | node-osx-notifier [port] [host] 34 | ``` 35 | 36 | The port and host will default to `1337` and `localhost` respectively. 37 | 38 | Testing The Server 39 | ------------------ 40 | You can then test that the server is running correctly by making a request to it. The simplest request uses the 41 | querystring over HTTP GET: 42 | 43 | ```sh 44 | curl "http://localhost:1337/info?message=test" 45 | ``` 46 | 47 | ```json 48 | { 49 | "status": "* Notification delivered." 50 | } 51 | ``` 52 | 53 | You can also use the JSON interface to POST the same content to the server: 54 | 55 | ```sh 56 | curl -H "Content-Type: application/json" -X POST -d '{"message":"test"}' "http://localhost:1338/info" 57 | ``` 58 | 59 | ```json 60 | { 61 | "status": "* Notification delivered." 62 | } 63 | ``` 64 | 65 | The HTTP API 66 | ------------ 67 | For starters, you want to pick from one of three notification types. The notification types are designated by the path 68 | of the server request. Each notification type changes the icon and section in the notification center: 69 | 70 | * _info_ `http://localhost:1337/info` used for basic notifications 71 | * ![info screenshot](http://f.cl.ly/items/0P3i301J281x1A0Q1L46/Screen%20Shot%202012-08-30%20at%201.19.18%20AM.png) 72 | * _pass_ `http://localhost:1337/pass` used for showing that a job has passed 73 | * ![info screenshot](http://f.cl.ly/items/0Q0A3b2S0v0Q2E3l0B0q/Screen%20Shot%202012-08-30%20at%201.21.03%20AM.png) 74 | * _fail_ `http://localhost:1337/fail` used for showing that a job has failed 75 | * ![info screenshot](http://f.cl.ly/items/1H3v2H173A0r3a2F3l0x/Screen%20Shot%202012-08-30%20at%201.19.57%20AM.png) 76 | 77 | In addition, you will also need to pass parameters (as JSON POST-data or a querystring) that tells the server what to 78 | do for a given notification type. Since the server acts as a wrapper, these parameters match 79 | [the command-line options](https://github.com/alloy/terminal-notifier#options) defined by the underlying apps. For 80 | completeness, those parameters are outlined below: 81 | 82 | At a minimum, you have to specify either the `-message` , the `-remove` 83 | option or the `-list` option. 84 | 85 | ------------------------------------------------------------------------------- 86 | 87 | `-message VALUE` **[required]** 88 | 89 | The message body of the notification. 90 | 91 | ------------------------------------------------------------------------------- 92 | 93 | `-title VALUE` 94 | 95 | The title of the notification. This defaults to ‘Terminal’. 96 | 97 | ------------------------------------------------------------------------------- 98 | 99 | `-subtitle VALUE` 100 | 101 | The subtitle of the notification. 102 | 103 | ------------------------------------------------------------------------------- 104 | 105 | `-group ID` 106 | 107 | Specifies the ‘group’ a notification belongs to. For any ‘group’ only _one_ 108 | notification will ever be shown, replacing previously posted notifications. 109 | 110 | A notification can be explicitely removed with the `-remove` option, describe 111 | below. 112 | 113 | Examples are: 114 | 115 | * The sender’s name to scope the notifications by tool. 116 | * The sender’s process ID to scope the notifications by a unique process. 117 | * The current working directory to scope notifications by project. 118 | 119 | ------------------------------------------------------------------------------- 120 | 121 | `-remove ID` **[required]** 122 | 123 | Removes a notification that was previously sent with the specified ‘group’ ID, 124 | if one exists. If used with the special group "ALL", all message are removed. 125 | 126 | ------------------------------------------------------------------------------- 127 | 128 | `-list ID` **[required]** 129 | 130 | Lists details about the specified ‘group’ ID. If used with the special group 131 | "ALL", details about all currently active messages are displayed. 132 | 133 | The output of this command is tab-separated, which makes it easy to parse. 134 | 135 | ------------------------------------------------------------------------------- 136 | 137 | `-activate ID` 138 | 139 | Specifies which application should be activated when the user clicks the 140 | notification. 141 | 142 | You can find the bundle identifier of an application in its `Info.plist` file 143 | _inside_ the application bundle. 144 | 145 | Examples are: 146 | 147 | * `com.apple.Terminal` to activate Terminal.app 148 | * `com.apple.Safari` to activate Safari.app 149 | 150 | ------------------------------------------------------------------------------- 151 | 152 | `-open URL` 153 | 154 | Specifies a resource to be opened when the user clicks the notification. This 155 | can be a web or file URL, or any custom URL scheme. 156 | 157 | ------------------------------------------------------------------------------- 158 | 159 | `-execute COMMAND` 160 | 161 | Specifies a shell command to run when the user clicks the notification. 162 | 163 | Licence 164 | ------- 165 | This project is dual licensed under the [MIT](https://github.com/azoff/node-osx-notifier/blob/master/LICENSE-MIT) 166 | license and defers to [any licensing defined by the underlying apps](https://github.com/alloy/terminal-notifier). 167 | 168 | 169 | Additional Support 170 | ------------------ 171 | If you're having problems with using the project, use the support forum at CodersClan. 172 | 173 | 174 | --------------------------------------------------------------------------------