Command-Line Interface for managing macOS Notification Center. It allows to:
- read all registered bundles in Notification Center;
- read bundle preferences;
- disable and enable notifications for a particular bundle identifier;
- manage concrete application settings:
- notifications style;
- notifications preview;
- enable/disable sound, badge app icons, critical alerts;
- disable system/all known apps notifications.
ncmanager deals with com.apple.ncprefs.plist, localed at directory $HOME/Library/Preferences. CLI writes new options to specified field, synchronise application preferences and relaunches NotificationCenter application.
Bundle preferences changes during a few seconds after the command is executed.
Bundle raw in a plist file contains flags key with Integer value. Actually, it is a bitmask in a decimal format, representing selected notification preferences for app.
| Option | Bitmask |
|---|---|
| badge_app_icon | 1 << 1 |
| sound_notifications | 1 << 2 |
| style_banners | 1 << 3 |
| style_alerts | 1 << 4 |
| allow_notifications | 1 << 25 |
| critical_alerts | 1 << 26 |
Every bundle has additional options for notification's preview and grouping. Keys and meanings are described below:
content_visibility- preview style for notifications;grouping- grouping style for notifications in Notification Center.
| Preview | Grouping | Value |
|---|---|---|
| default | automatic | 0 |
| never | byApplication | 1 |
| whenUnlocked | off | 2 |
| always | - | 3 |
ncmanager enables to forget about Mac Notification Center configuration.
- Disable/enable notifications for applications. Especially useful for macOS Integration(UI) test to avoid notifications overlapping the target app.
- Remotely manage macOS Notification Center.
- Manage your Mac preferences from Terminal. You can rely on CLI and forget about changing settings from Preferences.app.
- Disable annoying System Notifications from LaunchAgents, Tips and other build-in macOS application.
ncmanager is available in release artefacts. Also you can build CLI locally. To do this, follow next commands:
$ git clone NotificationCenterManager
$ cd NotificationCenterManager
$ swift build -c release --arch arm64 --arch x86_64Xcode 14.0 and higher is required to build package products.
You can integrate ncmanager in your Xcode project via SPM. Add the following dependency in your Package.swift:
dependencies: [
.package(
name: "ncmanager",
url: "https://github.com/AlexandrBilous/ncmanager.git",
from: "1.0.0")
]ncmanager is case-sensitive - make sure you use correct bundle identifier.
$ ncmanager write <bundle-id> [--icon <icon>] [--sound <sound>] [--notifications <notifications>] [--critical-alert <critical-alert>] [--alert-style <alert-style>] [--preview <preview>] [--grouping <grouping>]ncmanager supports reading all registered identifier in Notification Center and concrete bundle preferences with tiny output.
$ ncmanager read <subcommand>Command disables all notifications for applications with bundle identifier containing prefix _SYSTEM_CENTER_ or all applications, depends on selected input.
$ ncmanager disable --apps-type <apps-type> 