Files
SnipMC/Sources/AppDelegate.swift
T
marcoandClaude ecbae7cd21 Add URL scheme support for external trigger integration
Register snippingtool:// URL scheme so external tools (Logitech Options,
Shortcuts, Stream Deck) can trigger specific capture modes directly.
Adds AppDelegate for reliable URL handling in MenuBarExtra-only apps.

Supported URLs:
  snippingtool://fullscreen
  snippingtool://window
  snippingtool://region

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-01 16:03:25 +02:00

16 lines
657 B
Swift

import AppKit
/// MenuBarExtra-only apps (no WindowGroup) don't reliably receive SwiftUI's
/// `.onOpenURL` scene events — SwiftUI logs "Cannot use Scene methods for
/// URL... without using SwiftUI Lifecycle" and the handler never fires.
/// The classic AppKit delegate callback works regardless, so URL scheme
/// triggers (from Logitech Options, Shortcuts, Stream Deck, `open`, …) are
/// routed through here instead.
final class AppDelegate: NSObject, NSApplicationDelegate {
let coordinator = AppCoordinator()
func application(_ application: NSApplication, open urls: [URL]) {
urls.forEach { coordinator.handle(url: $0) }
}
}