diff --git a/Sources/Kapture/App.swift b/Sources/Kapture/App.swift index c336588..cac7aed 100644 --- a/Sources/Kapture/App.swift +++ b/Sources/Kapture/App.swift @@ -21,6 +21,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate { runOCRSelfTest() return } + // Single instance: stale copies keep their own hotkey + overlays alive + // after app updates and eat clicks meant for the new instance. + let myPid = ProcessInfo.processInfo.processIdentifier + let others = NSRunningApplication.runningApplications(withBundleIdentifier: "dev.tzgyn.kapture") + .filter { $0.processIdentifier != myPid } + if !others.isEmpty { + CaptureController.log("launch: other Kapture instances pids=\(others.map { String($0.processIdentifier) }.joined(separator: ",")) — terminating them") + for other in others { + other.forceTerminate() + } + } HotkeyManager.shared.onTrigger = { CaptureController.shared.begin() } HotkeyManager.shared.register() } diff --git a/build-app.sh b/build-app.sh index db88268..eecc9da 100755 --- a/build-app.sh +++ b/build-app.sh @@ -108,9 +108,9 @@ cat > "$APP/Contents/Info.plist" <<'PLIST' CFBundleIconFile Icon CFBundleShortVersionString - 1.6.4 + 1.6.5 CFBundleVersion - 64 + 65 LSUIElement NSHighResolutionCapable