Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

On OS X 10.8, users can disable Notification Center for a single day. Is there a way to check if it is enabled from the command line?.

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

You actually can find out if the Do Not Disturb is currently enabled or disabled. Notification Center drops a plist in the following location that you can read the value of. Run the following to find the plist file:

ls ~/Library/Preferences/ByHost/com.apple.notificationcenterui.*.plist

Now, you can read the value from the plist you just found by using:

defaults read ~/Library/Preferences/ByHost/com.apple.notificationcenterui.8D3EA20D-8D7F-52E2-9F99-BC17A13A3F0E.plist

NOTE: your actual filename may be different than what I have listed above.

You will see a key called "doNotDisturb" and it will either have a value of 1 or 0 (enabled or disabled)

You can also change it's status by doing:

defaults write ~/Library/Preferences/ByHost/com.apple.notificationcenterui.8D3EA20D-8D7F-52E2-9F99-BC17A13A3F0E.plist doNotDisturb 1

or:

defaults write ~/Library/Preferences/ByHost/com.apple.notificationcenterui.8D3EA20D-8D7F-52E2-9F99-BC17A13A3F0E.plist doNotDisturb 0

To make the change take effect, you'll need to restart Notification Center by typing:

killall NotificationCenter

I've actually written a very simple Automator script so now I can enable/disable the Do Not Disturb for Notification Center with a keyboard shortcut. Very handy. :)

share|improve this answer
add comment

Probably the best way I can think of is to install terminal notifier and send it a message from the terminal.

Install Terminal Notifier

Terminal notifier can be installed through Ruby Gems

Type:

sudo gem install terminal-notifier

Send NC a message

Type:

terminal-notifier -message "The notification center is running" -title "NC Status"

If notification center is running you'll get a message that says "The notification center is running"

share|improve this answer
    
The above worked well for me but it's a manual solution rather than a programmatic status indication so I'm not giving it a +1 as an answer to this question. It was however very useful in other respects. –  ClearCrescendo Jun 29 at 20:41
add comment

At the moment, the ways to interact with Notification Center programmatically (including via the command line) are pretty limited. As InfluenceJamie noted, there's terminal-notifier, which allows you to send notifications from the command line, but sending notifications is pretty much all programs can do at the moment. From my reading of the developer documentation, programs can only send and get information about the specific notifications they send, no status information for Notifcation Center itself, or other notifications. There's also no Applescript interface.

So at the moment, you're limited to manually testing whether a notification goes through, as InfluenceJamie suggested, or hoping that someone figures out Apple's private APIs and makes a command line interface.

share|improve this answer
    
In MacOS every preference is stored in some plist files, so there must be some "defaults read" stuff to do what I'm looking for. –  user732274 Aug 5 '12 at 22:54
1  
Well, that's a possibility of course, but the defaults are more for permanent preferences - a temporary setting might not be stored in the defaults. However that's probably your best bet if InfluenceJamie's suggestion doesn't work for you. –  robmathers Aug 5 '12 at 23:01
    
Where should this be stored if not in a plist? –  user732274 Aug 5 '12 at 23:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.