Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
Last active July 10, 2023 10:51
Show Gist options
  • Star 55 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mikermcneil/10005651 to your computer and use it in GitHub Desktop.
Save mikermcneil/10005651 to your computer and use it in GitHub Desktop.
Disable/Enable Notification Center (MacOS X)

Toggle MacOS X Notification Center on or off

This gist is to remind me (and anyone else who it helps) how to quickly disable and re-enable Notification Center.

Set Up Bash Aliases

Installation

  1. Open your terminal (<⌘ + ␣ (spacebar)>, then type "terminal", then press <↩ (enter)>).

  2. Paste and run the following command:

echo >> ~/.profile && echo >> ~/.profile && echo '# Disable/enable notification center' >> ~/.profile && echo 'alias disableNotificationCenter="launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist && killall NotificationCenter"' >> ~/.profile && echo 'alias enableNotificationCenter="launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist && open /System/Library/CoreServices/NotificationCenter.app/"' >> ~/.profile && source ~/.profile

Usage

To disable notification center:

disableNotificationCenter

To re-enable notification center:

enableNotificationCenter

How it works / background

Goal

Disable MacOS X's Notification Center entirely. But make it easy to turn it back on and disable again as needed.

Reasoning

I'm tired of seeing notifications that I can't dismiss, and there's no easy way to do this selectively (e.g. MacOS notifications always come through)

How this disables Notification Center

launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
killall NotificationCenter

How this re-enables Notification Center

launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
open /System/Library/CoreServices/NotificationCenter.app/

Bibliography

This approach is a command-line-only version of the solution proposed in a great article on osxdaily.com.

@mrmte
Copy link

mrmte commented Aug 31, 2018

It is never a good idea to disable the security settings Apple have put in place. By doing that you are making that system vulnerable.

@markhu
Copy link

markhu commented Sep 7, 2018

I'm running High Sierra, but for some reason I didn't need to disable anything before running the pkill NotificationCenter command. Alternate approaches are discussed at https://apple.stackexchange.com/questions/325547/how-do-i-dismiss-many-multiples-of-the-disk-not-ejected-properly-notification

@h4rm0n1c
Copy link

It is never a good idea to disable the security settings Apple have put in place. By doing that you are making that system vulnerable.

No more vulnerable than prior versions of OS X before SIP came along in the first place. If you're at the stage where all that's protecting you is SIP, you might as well give up on security entirely.

SIP is practically the same as the equivalent system file protection in Windows, if you are concerned about malicious software modifying system files, I'd be trying to prevent such software getting on my machines in the first place.

@DelphiDoop
Copy link

Is it possible to disable SIP, then disable notification center then re-enable SIP? I work in production and my macbook has one very specific use case, to run a program for production video, so I don't need notifications, however, I sometimes use this computer to browse the internet. Just wondering what the best solution is to disable notification center. I've already disabled each app.

@Tonyliu2ca
Copy link

It works: disable SIP, make your modifications, and then enable SIP.

@Whoaa512
Copy link

Doesn't work on Catalina, even with SIP disabled. However you can hold option (alt) and click on the Notification Center icon to disable it

@shadowbq
Copy link

shadowbq commented Jan 8, 2020

@Whoaa512 Catalina is supported with node/npm cli .. do-not-distrub on via https://github.com/sindresorhus/do-not-disturb-cli.
It basically just sets the doNotDisturb & dndprefs_changed with a 1440 minute count to dndEnd
Main library: https://raw.githubusercontent.com/sindresorhus/do-not-disturb/master/Sources/do-not-disturb/DoNotDisturb.swift

@Bozobee
Copy link

Bozobee commented Dec 26, 2020

EZ way. turn on 'do not disturb' for 23 hrs 59 min. I set mine to do not disturb from 4am to 3:59am

@ATM-NET
Copy link

ATM-NET commented Feb 10, 2021

-bash: enableNotificationCenter: command not found

@shiypc
Copy link

shiypc commented Apr 29, 2021

It is never a good idea to disable the security settings Apple have put in place. By doing that you are making that system vulnerable.

i disagree. disabling SIP would make it just as "vulnerable" as a linux machine, or even a vanilla unix machine.

@Bozobee
Copy link

Bozobee commented Apr 29, 2021 via email

@pradorocchi
Copy link

pradorocchi commented Jul 25, 2021

It is never a good idea to disable the security settings Apple have put in place. By doing that you are making that system vulnerable.

i disagree. disabling SIP would make it just as "vulnerable" as a linux machine, or even a vanilla unix machine.

Even disabling SIP completely it will not make easy for macOS to be vulnerable. It will be as like as any UNIX, (which is very secure).. etc..

BUT..
Better yet, there is another way, with no worries or concerns at all:

.

You can Partially disable SIP, in such a way that it:

  • Permits Stopping and Starting Services,
  • while still keeping the disk ReadOnly (on Catalina), and
  • keeping perfectly activated ALL other SIP protections.

.
Thus giving a bit more of advanced control to you, by being able to start and stop services, without compromising the system (as it could if you had fully disabled SIP)

To do it, boot using COMMAND+R, once on the recovery mode, open Terminal and type:

csrutil enable --without fs

You will be fulling enabling SIP, without FS (File System option), but since the MacOS partition is ReadOnly, you continue 100% protected about any possible system file change, and it gives you the advanced control to Start and Stop Services, making able for you to execute the lanchctl .. command described on this thread, and making full use of it.

I personally am using Catalina [latest 10.15.7 (19H1323)] with SIP configured this way. And I can assure you about the System Partition being fully read-only, and this option gives me the liberty that any advanced user [like me] wants or need sometimes]: to have a bit more control about the MacOS system.

..
After disabling and rebooting on normal mode, executing the SIP Status parameter, will show you this:

prado@MacBookPro ~                                                             [14:24:02]
> $ csrutil status
System Integrity Protection status: unknown (Custom Configuration).

Configuration:
	Apple Internal: disabled
	Kext Signing: enabled
	Filesystem Protections: disabled
	Debugging Restrictions: enabled
	DTrace Restrictions: enabled
	NVRAM Protections: enabled
	BaseSystem Verification: enabled




By doing it, you will have control to
to enable ou disable System Notification service, (or any other service via launchctl)
as described here on this topic.

.

(to revert, if you want to (e.g.) to fully re-enable SIP with ALL options, just type: sudo csrutil clear (can be done by sudo on MacOS Catalina without having to reboot on recovery, and for earlier versions: csrutil clear typed on Terminal of recovery console. This command resets SIP to being fully enabled on factory settings.

The beauty of MacOS is that we can customize it, and have any control we want over it, although sometimes is very hard to find out How to dig it :)

@shiypc
Copy link

shiypc commented Aug 31, 2021

to anyone using sierra or later, DO NOT LAUNCH SIRI WHILE USING THIS!! it causes a bunch of problems, and last time i tried, i wound up logging out entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment