Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Keep the Login Items row in place while macOS answers for it

Țugui Dragoșdcbc67451061
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index a9fcd82d..2f6e8ae3 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -50,10 +50,10 @@ struct BackgroundItemDetailView: View {
}
}
}
- if let legacyStatus {
+ if Self.hasLoginItemsStatus(item) {
LabeledContent("Login Items & Extensions") {
HStack(spacing: 8) {
- Text(legacyStatus)
+ Text(legacyStatus ?? "Checking…")
Button {
PrivilegedHelper.openLoginItemsSettings()
} label: {
@@ -296,23 +296,25 @@ struct BackgroundItemDetailView: View {
}
/// Returns the job's status in System Settings (Login Items & Extensions), or nil when it has no plist file in a
- /// folder launchd reads, the only ones `SMAppService.h` gives a status for. Per that header, `.requiresApproval`
- /// also means the user turned the job off, so the text says both. Off the main thread: `SMAppService` asks
- /// Background Task Management over XPC.
+ /// folder launchd reads (`hasLoginItemsStatus`), the only ones `SMAppService.h` gives a status for. Per that
+ /// header, `.requiresApproval` also means the user turned the job off, so the text says both. Off the main thread:
+ /// `SMAppService` asks Background Task Management over XPC.
@concurrent
static func legacyStatus(of item: BackgroundItem) async -> LocalizedStringResource? {
- guard let plistURL = item.plistURL, item.source == .userLibrary || item.source == .systemLibrary else {
- return nil
- }
+ guard let plistURL = item.plistURL, hasLoginItemsStatus(item) else { return nil }
return switch SMAppService.statusForLegacyPlist(at: plistURL) {
case .enabled: "Allowed"
case .requiresApproval: "Needs approval, or was turned off"
case .notRegistered: "Not registered"
case .notFound: "Not found"
- @unknown default: nil
+ @unknown default: "Unknown"
}
}
+ nonisolated static func hasLoginItemsStatus(_ item: BackgroundItem) -> Bool {
+ item.plistURL != nil && (item.source == .userLibrary || item.source == .systemLibrary)
+ }
+
private var header: some View {
HStack(spacing: 18) {
if let ownerURL = item.ownerURL {