Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NCutil.py can cause Do Not Disturb to be unset #12

Open
gregneagle opened this issue Apr 7, 2015 · 4 comments
Open

NCutil.py can cause Do Not Disturb to be unset #12

gregneagle opened this issue Apr 7, 2015 · 4 comments
Labels

Comments

@gregneagle
Copy link
Contributor

Steps to reproduce:

In Mavericks:
Set Do Not Disturb to On by pulling down the Notification Center from the menu bar
Use an NCutil.py command that alters NC settings.
Check the state of "Do Not Disturb" -- it's off again.

Yosemite does not seem to have this issue.

@gregneagle
Copy link
Contributor Author

This is triggered by the killall NotificationCenter that NCutil.py does after making a change. You can replicate the issue by turning on Do Not Disturb and then doing killall NotificationCenter.

This might not be fixable; at the very least a warning should be in the READ ME.

@jacobsalmela
Copy link
Owner

I added it to the README. I wonder if we can just use the defaults to read and write the value to stay what it is.

defaults read $HOME/Library/Preferences/ByHost/com.apple.notificationcenterui.*.plist doNotDisturb

0 is returned if it is off
1 if it is enabled

but this also uses a unique ID. The command above just uses a * but the real .plist has a name like com.apple.notificationcenterui.030C2F1F-D406-F25E-75A7-1C6C1865DE3E.plist

I'm sure there is a way to do it via a Python library, but I'm not familiar enough for that. I would probably just make a call out similar to how it's done for the killall NotificationCenter command.

@gregneagle
Copy link
Contributor Author

One uses the -currentHost flag to read and write ByHost preferences:

defaults -currentHost read com.apple.notificationcenterui

There are CFPreferences methods that can be called from Python to the same effect.

But being able to read/write this preference is not sufficient -- in Mavericks, the value there is never updated to match the UI (at least in my testing).

@gregneagle
Copy link
Contributor Author

In Mavericks:

% defaults -currentHost read com.apple.notificationcenterui
{
    doNotDisturb = 0;
    doNotDisturbMirrored = 1;
}

Now I pull down the Notification Center menu and enable Do Not Disturb. Then:

% defaults -currentHost read com.apple.notificationcenterui
{
    doNotDisturb = 0;
    doNotDisturbMirrored = 1;
}

No change. Values change as hoped/expected in Mountain Lion and Yosemite...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants