Adds a real-data LocalNetworkWidget to the HUD showing the Mac's approximate location (city/region via CLGeocoder reverse-geocode), the user's phone presence on the LAN (● HERE / ○ AWAY via Bonjour NWBrowser matching configured name patterns), and a live list of Bonjour-advertising LAN devices (iPhones, iPads, Macs, Apple TVs, HomePods, etc.) with a total count. All data is real — NWBrowser browses 13 service types continuously; CoreLocation supplies GPS coordinates reverse-geocoded to a place name. On first launch, macOS will prompt for Location Services permission; the widget gracefully shows "(awaiting permission)" until granted. Bonjour discovery is async — the device list starts empty and populates within a few seconds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
23 lines
775 B
Swift
23 lines
775 B
Swift
import Cocoa
|
|
|
|
final class AppDelegate: NSObject, NSApplicationDelegate {
|
|
private var statusItem: StatusItemController?
|
|
private var hudController: HUDWindowController?
|
|
|
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
|
// Start real-data services before creating the HUD so data flows immediately.
|
|
NetworkScanner.shared.start()
|
|
LocationProvider.shared.start()
|
|
|
|
let hud = HUDWindowController()
|
|
hudController = hud
|
|
hud.showWindow(nil)
|
|
|
|
let status = StatusItemController()
|
|
status.onFull = { [weak hud] in hud?.setFull() }
|
|
status.onCompact = { [weak hud] in hud?.setCompact() }
|
|
status.onHidden = { [weak hud] in hud?.setHidden() }
|
|
statusItem = status
|
|
}
|
|
}
|