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

ScreenSaverDefaults not updated in Sonoma #74

Open
Waitsnake opened this issue Jun 3, 2024 · 3 comments
Open

ScreenSaverDefaults not updated in Sonoma #74

Waitsnake opened this issue Jun 3, 2024 · 3 comments

Comments

@Waitsnake
Copy link
Owner

ScreenSaverDefaults are not updated in macOS Sonoma when changed in System Preferences because an old instance of legacyScreenSaver with older values is still running in background and this instance will be reused when activating the screen saver again. Since Sonoma macOS keeps the instance running instead closing legacyScreenSaver after screen saver was finished and not starting a new instance with new values from ScreenSaverDefaults as it worked with older macOS versions.
This new behaviour of macOS leads to the negative side effect that your new options will only shown in preview window of System Preferences (they create here a 2nd instance of legacyScreenSaver that they use correctly), but will be ignored by the real screen saver until you reboot your machine or maybe log off and log in your user account on macOS.

@Waitsnake
Copy link
Owner Author

I found a workaround here:
JohnCoates/Aerial#1305 (comment)

Adding a notification handler to "com.apple.screensaver.willstop" notification that executes a "exit(0)" will quit this old background instance when the screensaver is no longer used instead of keeping it running.

This has the positive side effect that the 'real screen saver' will use your new changed options and not only the preview window inside System Preferences.

Waitsnake added a commit that referenced this issue Jun 3, 2024
ScreenSaverDefaults are not updated in macOS Sonoma when changed in System Preferences because an old instance of legacyScreenSaver with older values is still running in background and re-used when activating the screen saver again instead closing of legacyScreenSaver and starting an new instance with new values from ScreenSaverDefaults.
Adding a notification handler to com.apple.screensaver.willstop with exit(0) will now quit this old background instance when the screensaver is stoped used instead of keeping it running and reuing it later.
@VETspert
Copy link

@Waitsnake Hi, can you tell me how this can be done? I am looking for a way to do this via MDM.
Thanks

@Waitsnake
Copy link
Owner Author

Waitsnake commented Sep 22, 2024

Ofc, but you could just have a look at the same files of this very commit #74 that is linked here where you asked your question. ;)

inside your method:
- (instancetype)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
start your own event handler method that i called "sonomaQuitWorkaround" for the event "com.apple.screensaver.willstop":

    // workaround for Sonoma
    if ([self isPreview] == FALSE)
    {
        [[NSDistributedNotificationCenter defaultCenter]
           addObserver:self
           selector:@selector(sonomaQuitWorkaround)
           name:@"com.apple.screensaver.willstop"
           object:nil];
    }

and here is the event handler that basically only calls function "exit(0)":

- (void) sonomaQuitWorkaround
{
    // workaround for Sonoma:
    // quit legacyScreenSaver when screensaver is stoped instead of keeping instance running in background as it is the case in Sonoma
    // problem with this running background legacyScreenSaver is that it keeps using old vales of ScreenSaverDefaults and ignores new options the user has done in the meantime.
    exit(0);
}

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

No branches or pull requests

2 participants