Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Background Items shows jobs that borrow a label of macOS
Țugui Dragoș0da22a6e77c5
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 253b20bf..2ecc9702 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -120581,6 +120581,112 @@}}},+ "This uses the name of one of macOS’s jobs" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Používá název jedné z úloh systému macOS"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Dieses Objekt verwendet den Namen eines Jobs von macOS"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Usa el nombre de una de las tareas de macOS"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Cet élément utilise le nom d’une tâche de macOS"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Usa il nome di uno degli elementi di macOS"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS固有のジョブの名前を使用しています"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS의 작업 이름 중 하나를 사용하는 항목입니다"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Dit gebruikt de naam van een taak van macOS"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ta rzecz używa nazwy jednego z zadań macOS"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Este item usa o nome de uma das tarefas do macOS"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Acesta folosește numele uneia dintre sarcinile macOS"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Этот объект использует имя одного из заданий macOS"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Det här använder namnet på ett av macOS egna jobb"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bu, macOS’in işlerinden birinin adını kullanıyor"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Цей елемент використовує назву одного із завдань macOS"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "此项使用了macOS某个任务的名称"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "此項目使用macOS某個工作的名稱"+ }+ }+ }+ },"Time Machine already leaves out some of these, through a folder above them or a rule of its own, so that part isn’t Peel’s to change." : {"localizations" : {"cs" : {@@ -149232,6 +149338,112 @@}}},+ "macOS runs a job by this name, but it didn’t install this file, so Peel doesn’t start, stop, or remove it here. Look at the file to see what put it there." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Systém macOS spouští úlohu s tímto názvem, ale tento soubor nenainstaloval, a proto ji tu Peel nespouští, nezastavuje ani neodstraňuje. Podívejte se do souboru, abyste zjistili, co ji tam umístilo."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS führt einen Job mit diesem Namen aus, hat diese Datei aber nicht installiert, daher startet, stoppt oder entfernt Peel ihn hier nicht. Sieh in der Datei nach, welche Software sie dort abgelegt hat."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS ejecuta una tarea con este nombre, pero no instaló este archivo, así que aquí Peel no la inicia, no la detiene ni la elimina. Mira el archivo para saber qué lo puso ahí."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS exécute une tâche portant ce nom, mais ce n’est pas macOS qui a installé ce fichier : Peel ne la démarre donc pas, ne l’arrête pas et ne la supprime pas ici. Examinez le fichier pour savoir ce qui l’a placé là."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS esegue un elemento con questo nome, ma non ha installato questo file, quindi qui Peel non lo avvia, non lo interrompe e non lo rimuove. Guarda il file per capire cosa l’ha messo lì."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOSはこの名前のジョブを実行しますが、このファイルはmacOSがインストールしたものではないため、Peelはここで開始、停止、ゴミ箱への移動を行いません。何がこれを置いたのかは、ファイルを見て確認してください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS가 이 이름으로 작업을 실행하지만 이 파일은 macOS가 설치한 것이 아니므로 Peel은 여기에서 이 항목을 시작, 중단 또는 제거하지 않습니다. 무엇이 이 항목을 넣어 두었는지 파일을 살펴보십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS voert een taak met deze naam uit, maar heeft dit bestand niet geïnstalleerd, dus Peel start, stopt of verwijdert het hier niet. Bekijk het bestand om te zien welke software het daar heeft neergezet."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS uruchamia zadanie o tej nazwie, ale nie zainstalował tego pliku, więc Peel go tutaj nie uruchamia, nie zatrzymuje ani nie przenosi do Kosza. Zajrzyj do pliku, aby sprawdzić, co go tam umieściło."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O macOS executa uma tarefa com este nome, mas não foi ele que instalou este arquivo, por isso o Peel não a inicia, não a interrompe nem a remove aqui. Veja no arquivo o que o colocou ali."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS rulează o sarcină cu acest nume, dar nu a instalat acest fișier, așa că Peel nu o pornește, nu o oprește și nu o elimină de aici. Examinați fișierul pentru a vedea ce l‑a pus acolo."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS запускает задание с таким именем, но этот файл установила не она, поэтому Peel здесь не запускает, не останавливает и не удаляет его. Загляните в файл, чтобы узнать, что его туда поместило."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS kör ett jobb med det här namnet, men har inte installerat den här filen, så Peel varken startar, stoppar eller tar bort det här. Titta i filen för att se vad som har lagt den där."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS bu adla bir iş çalıştırıyor ama bu dosyayı kendisi yüklemedi, bu yüzden Peel onu burada başlatmaz, durdurmaz veya kaldırmaz. Onu oraya neyin koyduğunu görmek için dosyaya bakın."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS виконує завдання з такою назвою, але цей файл вона не інсталювала, тож Peel тут його не запускає, не зупиняє й не вилучає. Перегляньте файл, щоб дізнатися, що його туди поклало."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS会运行使用此名称的任务,但此文件并非由macOS安装,因此Peel不会在此处启动、停止或移除它。请查看该文件,了解是什么将它放到了那里。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS會執行使用此名稱的工作,但這個檔案不是由macOS安裝的,因此Peel不會在這裡啟動、停止或移除它。請查看該檔案,瞭解是什麼將它放在那裡。"+ }+ }+ }+ },"macOS still counts this package as installed, but nothing it put on disk is left." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swiftindex 7187df60..c45d56db 100644--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift@@ -47,11 +47,17 @@ public struct BackgroundItem: Sendable, Hashable, Identifiable {/// installed and uninstalled only from Peel's Settings.public var isPeelsHelper: Bool { kind == .daemon && label == HelperIdentity.helperIdentifier }- /// True when the label starts with `com.apple.`. The scan leaves out the labels of macOS's own daemons, so a- /// listed job with an Apple label did not come with macOS. Peel shows it and never acts on it.+ /// True when the label starts with `com.apple.`.public var declaresAnAppleLabel: Bool { label.hasPrefix("com.apple.") }+ /// True when the label is Apple's, or one macOS gives a job of its own. macOS keeps its jobs under+ /// `/System/Library` and `/Library/Apple/System/Library`, never where the scan reads, so a listed job with+ /// such a label did not come with macOS. Peel shows it and never acts on it.+ public var usesALabelOfMacOS: Bool {+ declaresAnAppleLabel || SystemDaemons.shipped.contains(label) || SystemAgents.shipped.contains(label)+ }+public var removalRequiresPrivileges: Bool { source == .systemLibrary }- public var canMoveToTrash: Bool { source != .app && plistURL != nil && !declaresAnAppleLabel }+ public var canMoveToTrash: Bool { source != .app && plistURL != nil && !usesALabelOfMacOS }}diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swiftindex fd73a91e..60276269 100644--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift@@ -18,8 +18,7 @@ public enum BackgroundItemActions {/// would reach macOS's own job. The helper refuses one for a daemon, and the same answer holds here for an/// agent, which `launchctl` runs without the helper.static func refusal(for item: BackgroundItem) -> Failure? {- let usesMacOSsLabel = item.declaresAnAppleLabel || SystemDaemons.shipped.contains(item.label) || SystemAgents.shipped.contains(item.label)- return usesMacOSsLabel ? .launchctl(HelperRefusal.invalidRequest.rawValue) : nil+ item.usesALabelOfMacOS ? .launchctl(HelperRefusal.invalidRequest.rawValue) : nil}@concurrentdiff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swiftindex 8cc3430d..c97b6af7 100644--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift@@ -115,9 +115,9 @@ public enum BackgroundItems {var items: [BackgroundItem] = []for (folder, kind, source) in folders {for plist in plists(in: folder) where !exclusions.excludes(plist) {- // Skips a job with the label of one of macOS's own daemons. Any other `com.apple.` label is kept- // and shown, because a made-up Apple label is a common way to disguise a job.- guard let job = JobDefinition(contentsOf: plist), !SystemDaemons.shipped.contains(job.label), !SystemAgents.shipped.contains(job.label) else { continue }+ // A label of macOS's own is shown too, and marked (`usesALabelOfMacOS`): macOS keeps its jobs+ // elsewhere, so a file here that borrows one is somebody else's, and a common way to hide a job.+ guard let job = JobDefinition(contentsOf: plist) else { continue }let owner = ownership.owner(label: job.label, associated: job.associated, program: job.program)items.append(BackgroundItem(label: job.label,diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swiftindex 0b077ea0..5f29b40d 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift@@ -128,26 +128,32 @@ struct DeclaredBackgroundItemsTests {)}- @Test func readsTheJobEachFileDeclaresAndLeavesApplesOwnToMacOS() throws {+ /// macOS keeps its own jobs under `/System/Library` and `/Library/Apple/System/Library`, so a file in these+ /// folders that uses one of their labels, or any `com.apple.` label, is not macOS's. A label names a job only+ /// in its own domain, so such a copy runs beside the real one: it is listed, marked, and never acted on.+ @Test func showsAJobThatBorrowsALabelOfMacOSAndActsOnNone() throws {let directory = try TemporaryDirectory()try directory.file("home/Library/LaunchAgents/updater.plist", contents: job("com.example.agent", program: "/bin/sh"))try directory.file("root/Library/LaunchDaemons/com.example.helper.plist", contents: job("com.example.helper"))- // A label nobody but Apple should use, on a file macOS did not install: shown, and nothing acts on it.try directory.file("root/Library/LaunchDaemons/apple.plist", contents: job("com.apple.madeup.peeltest"))- // A label macOS itself declares is left out.- let shipped = try #require(SystemDaemons.shipped.first { $0.hasPrefix("com.apple.") })- try directory.file("root/Library/LaunchDaemons/shipped.plist", contents: job(shipped))- // So is a label one of macOS's own agents declares, whatever it says.+ let shipped = try #require(SystemDaemons.shipped.first { !$0.hasPrefix("com.apple.") })+ try directory.file("home/Library/LaunchAgents/daemon.plist", contents: job(shipped))try directory.file("home/Library/LaunchAgents/ssh.plist", contents: job("com.openssh.ssh-agent"))try directory.file("home/Library/LaunchAgents/unnamed.plist", contents: Data())try directory.file("home/Library/LaunchAgents/notes.txt")let items = BackgroundItems.declared(in: environment(directory), ownership: BackgroundItemOwnership(installedApps: []))- #expect(items.map(\.label).sorted() == ["com.apple.madeup.peeltest", "com.example.agent", "com.example.helper"])- let impostor = try #require(items.first { $0.declaresAnAppleLabel })- #expect(!impostor.canMoveToTrash)- #expect(items.first { $0.label == "com.example.agent" }?.canMoveToTrash == true)+ #expect(items.map(\.label).sorted() == ["com.apple.madeup.peeltest", "com.example.agent", "com.example.helper", "com.openssh.ssh-agent", shipped].sorted())+ for borrowed in items where borrowed.label != "com.example.agent" && borrowed.label != "com.example.helper" {+ #expect(borrowed.usesALabelOfMacOS, "\(borrowed.label)")+ #expect(!borrowed.canMoveToTrash, "\(borrowed.label)")+ #expect(BackgroundItemActions.refusal(for: borrowed) != nil, "\(borrowed.label)")+ }+ let own = try #require(items.first { $0.label == "com.example.agent" })+ #expect(!own.usesALabelOfMacOS)+ #expect(own.canMoveToTrash)+ #expect(BackgroundItemActions.refusal(for: own) == nil)}/// One label declared in two folders is two files, and each row opens its own.diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swiftindex 90940c8b..36d68e9a 100644--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift@@ -103,6 +103,14 @@ struct BackgroundItemDetailView: View {kind: .caution) {}}+ } else if item.usesALabelOfMacOS {+ Section {+ Notice(+ title: Text("This uses the name of one of macOS’s jobs"),+ detail: Text("macOS runs a job by this name, but it didn’t install this file, so Peel doesn’t start, stop, or remove it here. Look at the file to see what put it there."),+ kind: .caution+ ) {}+ }}if item.state == .unknown {@@ -159,9 +167,9 @@ struct BackgroundItemDetailView: View {}/// Whether this item needs administrator access while the helper can't act. Never true for Peel's own helper- /// or a job with an Apple label: neither offers an action, so the helper would change nothing.+ /// or a job under one of macOS's labels: neither offers an action, so the helper would change nothing.private var needsHelper: Bool {- !item.isPeelsHelper && !item.declaresAnAppleLabel && (item.requiresPrivileges || item.removalRequiresPrivileges) && !helper.canAct+ !item.isPeelsHelper && !item.usesALabelOfMacOS && (item.requiresPrivileges || item.removalRequiresPrivileges) && !helper.canAct}private var finderURL: URL? {@@ -251,10 +259,10 @@ struct BackgroundItemDetailView: View {.contentTransition(.opacity)}- /// Start, Stop, Enable, and Disable, which Peel's own helper, a job under one of Apple's names, and a job whose+ /// Start, Stop, Enable, and Disable, which Peel's own helper, a job under one of macOS's labels, and a job whose/// state Peel could not read don't have.private var hasOwnControls: Bool {- !item.isPeelsHelper && !item.declaresAnAppleLabel && item.state != .unknown+ !item.isPeelsHelper && !item.usesALabelOfMacOS && item.state != .unknown}private var controls: some View {