← All repositories

listless

A simple list app for Apple platforms

git clone https://code.inqk.net/listless.git


commit b351669359e1f6e6353f5d046403f72d7441f501
parent 3202f4afb9f89a7b1a35add831907644cce2c07e
Author: Michael Camilleri <[email protected]>
Date:   Fri,  6 Mar 2026 12:52:38 +0900

Avoid macOS version opening on CloudKit sync

Diffstat

MListlessMac/ListlessMacApp.swift | 18++++++++++++++++++

1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/ListlessMac/ListlessMacApp.swift b/ListlessMac/ListlessMacApp.swift

@@ -20,11 +20,29 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
     }
 
     func applicationDidFinishLaunching(_ notification: Notification) {
+        // When the system launches the app for background work (e.g. CloudKit
+        // sync), there is no Apple Event. Only open a window for user-initiated
+        // launches; terminate otherwise so the app doesn't linger.
+        guard
+            let event = NSAppleEventManager.shared().currentAppleEvent,
+            event.eventID == kAEOpenApplication
+        else {
+            NSApp.terminate(nil)
+            return
+        }
+
         NSWindow.allowsAutomaticWindowTabbing = false
         installMainMenu()
         openNewWindow()
     }
 
+    func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
+        if !flag {
+            openNewWindow()
+        }
+        return true
+    }
+
     func applicationDidUnhide(_ notification: Notification) {
         NSApp.keyWindow?.makeFirstResponder(nil)
     }