Something went wrong. Try again.
Monorepo for Aesthetic.Computer aesthetic.computer
Something went wrong. Try again.
3.6 kB · 74 lines
Swift
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475// 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 <track>.juke.json so the notes survive re-renders.//// Usage:// jukewizard [<playlist.m3u8 | folder | file.mp3> ...] [--watch <dir>]// bin/jukewizard --queue <file.mp3> <file.mp3> focused ordered queue// (no args → opens ~/Desktop/MASTER-playlist.m3u8 if present)//// --watch <dir> 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 [<playlist.m3u8 | folder | file.mp3> ...] [--select <file>] [--watch <dir>]") 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.sharedlet delegate = JukeAppDelegate()app.delegate = delegateapp.setActivationPolicy(.regular)app.run()