From 2062212b7896bad1fa2803aba1b798869c1076f8 Mon Sep 17 00:00:00 2001 From: Robert Beeger Date: Sat, 14 Oct 2023 18:26:11 +0200 Subject: [PATCH] Fix not being able to change settings and breaking animations on subsequent starts of the screensaver --- Epigraver/Main.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Epigraver/Main.swift b/Epigraver/Main.swift index a9dfc2b..27010af 100644 --- a/Epigraver/Main.swift +++ b/Epigraver/Main.swift @@ -48,6 +48,19 @@ class Main: ScreenSaverView { let timingFunction = CAMediaTimingFunction( controlPoints: 0.25, .random(in: 0.2...1.0), 0.75, .random(in: 0.2...1.0)) selectedAnimator.setup(boxes: textDisplayBoxes, with: timingFunction) + + if !isPreview { + // https://www.jwz.org/blog/2023/10/xscreensaver-6-08-out-now/ + DistributedNotificationCenter.default.addObserver( + self, + selector: #selector(willStop), + name: Notification.Name("com.apple.screensaver.willstop"), object: nil + ) + } + } + + @objc func willStop() { + NSApplication.shared.terminate(self) } func resetAnimator(animator: Animator) {