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.

Lead from an Intel background item to its row in Background Items

Țugui Dragoșa67827d85f33
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index d812c644..e6fd80ed 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -145677,6 +145677,112 @@
}
}
},
+ "Review in Background Items" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Zkontrolovat na stránce Položky na pozadí"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "In „Hintergrundobjekte“ prüfen"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Revisar en Ítems en segundo plano"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Examiner dans Éléments en arrière-plan"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Rivedi in “Elementi in background”"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "“バックグラウンド項目”で確認"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "백그라운드 항목 페이지에서 검토"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bekijk in 'Achtergrondonderdelen'"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Przejrzyj w Rzeczach działających w tle"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Revisar em Itens em Segundo Plano"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Revizuiți în Articole de fundal"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Показать в разделе «Фоновые объекты»"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Granska i Bakgrundsobjekt"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Arka Plan Öğeleri’nde İncele"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Переглянути в розділі «Фонові елементи»"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "在后台项目中检查"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "在「背景項目」中檢視"
+ }
+ }
+ }
+ },
"Review in Plug-ins" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift b/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift
index e2e7ff23..6caae63c 100644
--- a/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift
@@ -24,6 +24,8 @@ public struct IntelFinding: Sendable, Hashable, Identifiable {
public var pluginCategory: Plugin.Category?
/// The labels of the launchd jobs that run a program at it or inside it.
public var backgroundItems: [String] = []
+ /// For a background item, its row on the Background Items page (`BackgroundItem.id`).
+ public var job: BackgroundItem.ID?
public var id: URL { url }
}
@@ -212,13 +214,15 @@ public enum IntelInspector {
continue
}
guard isIntelOnly(executable: program, unreadable: &unreadable), isNew(program) else { continue }
- findings.append(IntelFinding(
+ var finding = IntelFinding(
url: program,
kind: .backgroundItem,
name: item.label,
owner: item.plistURL?.lastPathComponent,
size: await measure(program),
- ))
+ )
+ finding.job = item.id
+ findings.append(finding)
listed.append(path)
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift
index dbe5842e..ecfb0527 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift
@@ -429,6 +429,7 @@ struct IntelInspectorTests {
#expect(scan.findings.count == 1)
#expect(Set(scan.findings.map(\.id)).count == 1)
+ #expect(scan.findings.first?.job == job("com.example.one").id, "Background Items couldn't show its row")
}
/// Whatever sits where an executable is named gets opened, and a named pipe opened for reading waits for its
diff --git a/Peel/Views/Intel/IntelDetailView.swift b/Peel/Views/Intel/IntelDetailView.swift
index 7d4c5af6..d87f6f01 100644
--- a/Peel/Views/Intel/IntelDetailView.swift
+++ b/Peel/Views/Intel/IntelDetailView.swift
@@ -5,6 +5,7 @@ import SwiftUI
struct IntelDetailView: View {
@Environment(AppLibrary.self) private var library
@Environment(PluginLibrary.self) private var plugins
+ @Environment(BackgroundItemLibrary.self) private var backgroundItems
let finding: IntelFinding
/// When `app` was last opened, for an app or a bundle inside one. Read from the list, which follows it, since
@@ -111,7 +112,7 @@ struct IntelDetailView: View {
Section {
HStack {
// Show in Finder is centered when alone, and goes first when a Review button is beside it.
- if app == nil, !finding.isOnThePlugInsPage {
+ if app == nil, !finding.isOnThePlugInsPage, finding.job == nil {
Spacer()
}
Button("Show in Finder", systemImage: "folder") {
@@ -136,6 +137,12 @@ struct IntelDetailView: View {
Navigator.shared.requestedTool = .plugins
}
.buttonStyle(.borderedProminent)
+ } else if let job = finding.job {
+ Button("Review in Background Items", systemImage: "gearshape.2") {
+ backgroundItems.selection = job
+ Navigator.shared.requestedTool = .backgroundItems
+ }
+ .buttonStyle(.borderedProminent)
}
}
} header: {