// JukeWizard — a native macOS popup for selecting, rating, and annotating // tracks. Sibling of wave-wizard + clip-wizard. Play a queue of audio // (a folder, an .m3u/.m3u8 playlist, or loose files), leave 1–5 stars, // freeform notes, and comments pinned to timestamps — all saved beside // each track as .juke.json so the notes survive re-renders. // // Usage: // jukewizard [ ...] [--watch ] // bin/jukewizard --queue focused ordered queue // (no args → opens ~/Desktop/MASTER-playlist.m3u8 if present) // // --watch auto-pop: when a fresh audio file lands here, add it // to the queue and start playing (repeatable). import AppKit final class JukeAppDelegate: NSObject, NSApplicationDelegate { var controller: JukeController? func applicationDidFinishLaunching(_ notification: Notification) { DockIcon.install(prefix: "jukewizard") let args = Array(CommandLine.arguments.dropFirst()) var watch: [String] = [] var paths: [String] = [] var selectPath: String? = nil var i = 0 while i < args.count { if args[i] == "--watch", i + 1 < args.count { watch.append(args[i + 1]); i += 2; continue } if args[i] == "--select", i + 1 < args.count { selectPath = args[i + 1]; i += 2; continue } paths.append(args[i]); i += 1 } if paths.isEmpty { let master = NSHomeDirectory() + "/Desktop/MASTER-playlist.m3u8" if FileManager.default.fileExists(atPath: master) { paths = [master] } } let library = Library(inputs: paths) // Make sure the requested track is in the queue even if it's a draft // not yet in the library index — so we can always select + play it. if let sp = selectPath { let u = URL(fileURLWithPath: (sp as NSString).expandingTildeInPath) if !library.tracks.contains(where: { $0.url.standardizedFileURL.path == u.standardizedFileURL.path }) { let lane = u.deletingLastPathComponent().deletingLastPathComponent().lastPathComponent library.addFile(u, lane: lane) } } guard !library.tracks.isEmpty else { print("JukeWizard: no tracks found.") print("usage: jukewizard [ ...] [--select ] [--watch ]") NSApp.terminate(nil); return } controller = JukeController(library: library, watch: watch, select: selectPath) controller?.showWindow(nil) NSApp.activate(ignoringOtherApps: true) } // Stay resident when the window closes — the spinning-CD menu-bar item is // JukeWizard's persistent face; click it to bring the window back. func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { false } // A hidden resident window should always come back from a Dock click. // Without this, AppKit can activate the process while leaving its only // window closed, which looks indistinguishable from a crash. func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { if !flag { controller?.showWindow(nil) } controller?.window?.makeKeyAndOrderFront(nil) NSApp.activate(ignoringOtherApps: true) return true } } let app = NSApplication.shared let delegate = JukeAppDelegate() app.delegate = delegate app.setActivationPolicy(.regular) app.run()