{"id":16006611,"url":"https://github.com/codebytere/node-mac-notify","last_synced_at":"2025-11-25T22:04:30.995Z","repository":{"id":190012932,"uuid":"681762734","full_name":"codebytere/node-mac-notify","owner":"codebytere","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-22T10:39:02.000Z","size":110,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-14T07:25:54.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codebytere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-22T17:51:09.000Z","updated_at":"2023-09-03T03:08:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"89031da5-2fe2-46a8-8b5b-d13b633d3b0f","html_url":"https://github.com/codebytere/node-mac-notify","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"388582822b78a839061a5535908bf97d89c0eed9"},"previous_names":["codebytere/node-mac-notify"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-notify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-notify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-notify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-notify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codebytere","download_url":"https://codeload.github.com/codebytere/node-mac-notify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241430321,"owners_count":19961635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T11:42:44.927Z","updated_at":"2025-11-25T22:04:30.924Z","avatar_url":"https://github.com/codebytere.png","language":"Objective-C++","readme":"[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)\n [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![Actions Status](https://github.com/codebytere/node-mac-notify/workflows/Test/badge.svg)](https://github.com/codebytere/node-mac-notify/actions)\n\n# node-mac-notify\n\n## Overview\n\n```js\n$ npm i node-mac-notify\n```\n\nThis native Node.js module allows you to send and monitor Darwin-style notifications on macOS.\n\nThe Darwin-style notification API allow processes to exchange stateless notification events.\tProcesses post notifications to a single system-wide notification server, which then distributes notifications to client processes that have registered to receive those notifications, including processes run by other users.\n\nNotifications are associated with names in a namespace shared by all clients of the system.  Clients may post notifications for names, and may monitor names for posted notifications.  Clients may request notification delivery by a number of different methods.\n\nClients desiring to monitor names in the notification system must register with the system, providing a name and other information required for the desired notification delivery method. Clients that use signal-based notification should be aware that signals are not delivered to a process while it is running in a signal handler. This may affect the delivery of signals in close succession.\n\nNotifications may be coalesced in some cases.  Multiple events posted for a name in rapid succession may result in a single notification sent to clients registered for notification for that name.\n\nSee [Apple Documentation](https://developer.apple.com/documentation/darwinnotify) or the [Unix Man Page](https://www.unix.com/man-page/osx/3/notify).\n\n## API\n\n### `notify.postNotification(name)`\n\n* `name` String - The event name to post a notification for.\n\nReturns `Boolean` - Whether or not the notification was successfully posted.\n\nExample:\n```js\nconst { postNotification } = require('node-mac-notify')\n\nconst name = 'my-event-name'\n\nconst posted = postNotification(name)\nconsole.log(`Notification for ${name} was ${posted ? 'successfully' : 'unsuccessfully'} posted.`)\n```\n\nThis method wraps [`notify_post`](https://www.unix.com/man-page/osx/3/notify_post).\n\n\n### `notify.getState(name)`\n\n* `name` String - The event name to fetch the current state for.\n\nReturns [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) - The current state of `name`.\n\nExample:\n```js\nconst { getState, listener } = require('node-mac-notify')\n\nconst name = 'my-event-name'\n\nconst added = listener.add(name)\nconsole.log(`Event handler for ${name} was ${added ? 'successfully' : 'unsuccessfully'} added.`)\n\nconst state = getState(name)\nconsole.log(`Current state of ${name} is ${state}`)\n```\n\nThis method wraps [`notify_get_state`](https://www.unix.com/man-page/osx/3/notify_get_state).\n\n### `notify.setState(name, state)`\n\n* `name` String - The event name to set the state for.\n* `state` [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) - Integer value of the new state.\n\nReturns `Boolean` - Whether or not the new state was successfully set for `name`.\n\nExample:\n```js\nconst { getState, listener } = require('node-mac-notify')\n\nconst name = 'my-event-name'\n\nconst added = listener.add(name)\nconsole.log(`Event handler for ${name} was ${added ? 'successfully' : 'unsuccessfully'} added.`)\n\nconst newState = 5\nconst success = setState(name, newState)\nconsole.log(`State for ${name} was ${success ? 'successfully' : 'unsuccessfully'} set to ${newState}.`)\n```\n\nThis method wraps [`notify_set_state`](https://www.unix.com/man-page/osx/3/notify_set_state).\n\n### `notify.listener`\n\nThis module exposes an `EventEmitter`, which can be used to listen and manipulate notifications.\n\n#### `notify.listener.add(name)`\n\n* `name` String - The event name to add an event handler for.\n\nRegisters a event handler for the event with name `name`.\n\n```js\nconst { listener } = require('node-mac-notify')\n\nconst name = 'my-event-name'\n\nconst added = listener.add(name)\nconsole.log(`Event handler for ${name} was ${added ? 'successfully' : 'unsuccessfully'} added.`)\n\nlistener.on(name, () =\u003e {\n  console.log(`An notification was posted for ${name}!`)\n})\n```\n\nThis method wraps [`notify_register_dispatch`](https://www.unix.com/man-page/osx/3/notify_register_dispatch).\n\n#### `notify.listener.remove(name)`\n\n* `name` String - The event name to remove an existing event handler for.\n\nRemoves a event handler for the event with name `name`.\n\n```js\nconst { listener } = require('node-mac-notify')\n\nconst name = 'my-event-name'\n\nlistener.add(name)\n\nconst removed = listener.remove(name)\nconsole.log(`Event handler for ${name} was ${removed ? 'successfully' : 'unsuccessfully'} removed.`)\n```\n\nThis method wraps [`notify_cancel`](https://www.unix.com/man-page/osx/3/notify_cancel).\n\n#### `notify.listener.suspend(name)`\n\n* `name` String - The event name to suspend an existing event handler for.\n\nSuspends a event handler for the event with name `name`.\n\n```js\nconst { listener } = require('node-mac-notify')\n\nconst name = 'my-event-name'\n\nlistener.add(name)\n\nconst suspended = listener.suspend(name)\nconsole.log(`Event handler for ${name} was ${suspended ? 'successfully' : 'unsuccessfully'} suspended.`)\n```\n\nThis method wraps [`notify_suspend`](https://www.unix.com/man-page/osx/3/notify_suspend).\n\n#### `notify.listener.resume(name)`\n\n* `name` String - The event name to resume an suspended event handler for.\n\nResumes a suspended event handler for the event with name `name`.\n\n```js\nconst { listener } = require('node-mac-notify')\n\nconst name = 'my-event-name'\n\nlistener.add(name)\n\nconst suspended = listener.suspend(name)\nif (suspended) {\n  const resumed = listener.resume(name)\n  console.log(`Suspended event handler for ${name} was ${resumed ? 'successfully' : 'unsuccessfully'} resumed.`)\n}\n```\n\nThis method wraps [`notify_resume`](https://www.unix.com/man-page/osx/3/notify_resume).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebytere%2Fnode-mac-notify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebytere%2Fnode-mac-notify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebytere%2Fnode-mac-notify/lists"}