Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bilousoleksandr/ncmanager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NotificationCenterManager


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.

How it works

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.

Flags

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

Use-cases

ncmanager enables to forget about Mac Notification Center configuration.

  1. Disable/enable notifications for applications. Especially useful for macOS Integration(UI) test to avoid notifications overlapping the target app.
  2. Remotely manage macOS Notification Center.
  3. Manage your Mac preferences from Terminal. You can rely on CLI and forget about changing settings from Preferences.app.
  4. Disable annoying System Notifications from LaunchAgents, Tips and other build-in macOS application.

Installation

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_64

Xcode 14.0 and higher is required to build package products.

Swift Package Manager

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")
]

Usage

ncmanager is case-sensitive - make sure you use correct bundle identifier.

Change bundle preferences

    $ ncmanager write <bundle-id> [--icon <icon>] [--sound <sound>] [--notifications <notifications>] [--critical-alert <critical-alert>] [--alert-style <alert-style>] [--preview <preview>] [--grouping <grouping>]

Read preferences

ncmanager supports reading all registered identifier in Notification Center and concrete bundle preferences with tiny output.

    $ ncmanager read <subcommand>

Output format

Disable notifications

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>  

References and Credits

  • Kolide - an powerful article with Notification Center bitfields description.
  • NCUtil - python script for Notification Center Management

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages