Working lock screen widget

This commit is contained in:
Hariharan Mudaliar 2025-10-17 17:26:46 +05:30
commit 44b18513f2
13 changed files with 705 additions and 3 deletions

View file

@ -295,6 +295,18 @@ struct GeneralSettings: View {
} footer: {
Text("Shows green camera icon and yellow microphone icon when in use. Uses event-driven CoreAudio and CoreMediaIO APIs.")
}
Section {
Defaults.Toggle("Enable Lock Screen Live Activity", key: .enableLockScreenLiveActivity)
Button("Copy Latest Crash Report") {
copyLatestCrashReport()
}
} header: {
Text("Lock Screen")
} footer: {
Text("Shows a lock icon in the Dynamic Island when the screen is locked. The lock screen music panel can be toggled separately in Media settings.")
}
Section {
Picker(selection: $notchHeightMode, label:
@ -373,6 +385,43 @@ struct GeneralSettings: View {
}
}
}
private func copyLatestCrashReport() {
let crashReportsPath = NSString(string: "~/Library/Logs/DiagnosticReports").expandingTildeInPath
let fileManager = FileManager.default
do {
let files = try fileManager.contentsOfDirectory(atPath: crashReportsPath)
let crashFiles = files.filter { $0.contains("DynamicIsland") && $0.hasSuffix(".crash") }
guard let latestCrash = crashFiles.sorted(by: >).first else {
let alert = NSAlert()
alert.messageText = "No Crash Reports Found"
alert.informativeText = "No crash reports found for DynamicIsland"
alert.alertStyle = .informational
alert.runModal()
return
}
let crashPath = (crashReportsPath as NSString).appendingPathComponent(latestCrash)
let crashContent = try String(contentsOfFile: crashPath, encoding: .utf8)
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(crashContent, forType: .string)
let alert = NSAlert()
alert.messageText = "Crash Report Copied"
alert.informativeText = "Crash report '\(latestCrash)' has been copied to clipboard"
alert.alertStyle = .informational
alert.runModal()
} catch {
let alert = NSAlert()
alert.messageText = "Error"
alert.informativeText = "Failed to read crash reports: \(error.localizedDescription)"
alert.alertStyle = .warning
alert.runModal()
}
}
@ViewBuilder
func gestureControls() -> some View {
@ -709,6 +758,12 @@ struct Media: View {
customBadge(text: "Beta")
}
}
// Enable/disable the lock screen media widget
Defaults.Toggle(key: .enableLockScreenMediaWidget) {
HStack {
Text("Enable lock screen media widget")
}
}
} header: {
Text("Media controls")
}