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.

Say when a background item's file is gone, and let it be stopped

Țugui Dragoșd61cbfd8206f
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 86db6d72..16eaa508 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -69349,6 +69349,324 @@
}
}
},
+ "Its file is gone" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Její soubor zmizel"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seine Datei ist nicht mehr vorhanden"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Su archivo ya no está"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Son fichier a disparu"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il suo file non c’è più"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "この項目のファイルがなくなっています"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "파일이 사라짐"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het bestand is verdwenen"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Pliku tej rzeczy już nie ma"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O arquivo dele não existe mais"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Fișierul său nu mai există"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Его файла больше нет"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Filen är borta"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Dosyası artık yok"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Його файлу вже немає"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的文件已不存在"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的檔案已不存在"
+ }
+ }
+ }
+ },
+ "Its file was removed while it was loaded, so macOS runs it until the Mac restarts and nothing starts it again. Stop takes it out now." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Její soubor byl odstraněn, zatímco byla načtená, takže ji systém macOS nechá běžet až do restartu Macu a nic ji znovu nespustí. Tlačítko Zastavit ji odebere hned."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seine Datei wurde entfernt, während es geladen war, daher führt macOS es aus, bis der Mac neu startet, und nichts startet es erneut. „Stoppen“ beendet es sofort."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Su archivo se eliminó mientras estaba cargado, así que macOS lo sigue ejecutando hasta que el Mac se reinicie, y nada lo vuelve a iniciar. “Detener” lo quita ahora."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Son fichier a été supprimé alors qu’il était chargé : macOS l’exécute donc jusqu’au redémarrage du Mac, et rien ne le relancera ensuite. Le bouton Arrêter le retire de launchd dès maintenant."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il suo file è stato rimosso mentre era caricato, quindi macOS lo esegue fino al riavvio del Mac e poi nulla lo avvierà di nuovo. Il pulsante Interrompi lo toglie subito."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "読み込まれている間にファイルが取り除かれたため、macOSはMacを再起動するまでこれを実行し続けますが、再び起動するものはありません。“停止”で今すぐ取り除けます。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "로드되어 있는 동안 파일이 제거되었으므로, macOS는 Mac을 재시동할 때까지 이 항목을 실행하며 그 후에는 아무것도 이 항목을 다시 시작하지 않습니다. ‘중단’을 클릭하면 지금 launchd에서 제거됩니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het bestand ervan is verwijderd terwijl het geladen was, dus macOS voert het uit totdat de Mac opnieuw opstart, en daarna start niets het opnieuw. 'Stop' haalt het nu weg."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Jej plik usunięto, gdy była wczytana, więc macOS utrzymuje ją w działaniu aż do ponownego uruchomienia Maca, a potem nic jej już nie uruchomi. Przycisk Zatrzymaj od razu usunie ją z launchd."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O arquivo dele foi removido enquanto ele estava carregado, então o macOS o executa até o Mac ser reiniciado, e depois disso nada o inicia novamente. O botão Parar o retira do launchd agora."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Fișierul său a fost eliminat cât timp era încărcat, așa că macOS îl rulează până când Mac‑ul repornește și nimic nu îl mai pornește după aceea. „Opriți” îl scoate chiar acum."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Его файл удалили, пока он был загружен, поэтому macOS выполняет его до перезагрузки Mac, и ничто не запустит его снова. Кнопка «Остановить» уберет его прямо сейчас."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Filen togs bort medan jobbet var inläst, så macOS kör det tills datorn startas om, och inget startar det igen. ”Stoppa” tar bort det ur launchd nu."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Dosyası, öğe yüklüyken kaldırıldı, bu yüzden macOS onu Mac yeniden başlayana kadar çalıştırır ve ardından hiçbir şey onu yeniden başlatmaz. Durdur düğmesi onu şimdi devreden çıkarır."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Його файл вилучено, поки елемент був завантажений, тож macOS виконує його до перезапуску Mac, і ніщо не запустить його знову. Кнопка «Зупинити» вилучає його вже зараз."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的文件在它载入期间被移除,因此macOS会一直运行它直到Mac重新启动,之后也不会有任何程序再次启动它。“停止”会立即将它从launchd中移除。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的檔案在它載入期間被移除,因此macOS會執行它直到Mac重新開機,之後也不會有任何東西再次啟動它。「停止」會立即將它移除。"
+ }
+ }
+ }
+ },
+ "Its file was removed while it was loaded, so macOS runs it until you log out and nothing starts it again. Stop takes it out now." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Její soubor byl odstraněn, zatímco byla načtená, takže ji systém macOS nechá běžet, dokud se neodhlásíte, a nic ji znovu nespustí. Tlačítko Zastavit ji odebere hned."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seine Datei wurde entfernt, während es geladen war, daher führt macOS es aus, bis du dich abmeldest, und nichts startet es erneut. „Stoppen“ beendet es sofort."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Su archivo se eliminó mientras estaba cargado, así que macOS lo sigue ejecutando hasta que cierres sesión, y nada lo vuelve a iniciar. “Detener” lo quita ahora."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Son fichier a été supprimé alors qu’il était chargé : macOS l’exécute donc jusqu’à ce que vous fermiez la session, et rien ne le relancera ensuite. Le bouton Arrêter le retire de launchd dès maintenant."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il suo file è stato rimosso mentre era caricato, quindi macOS lo esegue fino al logout e poi nulla lo avvierà di nuovo. Il pulsante Interrompi lo toglie subito."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "読み込まれている間にファイルが取り除かれたため、macOSはログアウトするまでこれを実行し続けますが、再び起動するものはありません。“停止”で今すぐ取り除けます。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "로드되어 있는 동안 파일이 제거되었으므로, macOS는 사용자가 로그아웃할 때까지 이 항목을 실행하며 그 후에는 아무것도 이 항목을 다시 시작하지 않습니다. ‘중단’을 클릭하면 지금 launchd에서 제거됩니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het bestand ervan is verwijderd terwijl het geladen was, dus macOS voert het uit totdat je uitlogt, en daarna start niets het opnieuw. 'Stop' haalt het nu weg."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Jej plik usunięto, gdy była wczytana, więc macOS utrzymuje ją w działaniu, dopóki się nie wylogujesz, a potem nic jej już nie uruchomi. Przycisk Zatrzymaj od razu usunie ją z launchd."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O arquivo dele foi removido enquanto ele estava carregado, então o macOS o executa até você finalizar a sessão, e depois disso nada o inicia novamente. O botão Parar o retira do launchd agora."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Fișierul său a fost eliminat cât timp era încărcat, așa că macOS îl rulează până când faceți logout și nimic nu îl mai pornește după aceea. „Opriți” îl scoate chiar acum."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Его файл удалили, пока он был загружен, поэтому macOS выполняет его, пока Вы не выйдете из системы, и ничто не запустит его снова. Кнопка «Остановить» уберет его прямо сейчас."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Filen togs bort medan jobbet var inläst, så macOS kör det tills du loggar ut, och inget startar det igen. ”Stoppa” tar bort det ur launchd nu."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Dosyası, öğe yüklüyken kaldırıldı, bu yüzden macOS onu siz oturumu kapatana kadar çalıştırır ve ardından hiçbir şey onu yeniden başlatmaz. Durdur düğmesi onu şimdi devreden çıkarır."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Його файл вилучено, поки елемент був завантажений, тож macOS виконує його, доки ви не вийдете із системи, і ніщо не запустить його знову. Кнопка «Зупинити» вилучає його вже зараз."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的文件在它载入期间被移除,因此macOS会一直运行它直到你退出登录,之后也不会有任何程序再次启动它。“停止”会立即将它从launchd中移除。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的檔案在它載入期間被移除,因此macOS會執行它直到你登出,之後也不會有任何東西再次啟動它。「停止」會立即將它移除。"
+ }
+ }
+ }
+ },
"Its maker has deprecated it." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
index 2d4ed11e..4d354677 100644
--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
@@ -63,6 +63,9 @@ public struct BackgroundItem: Sendable, Hashable, Identifiable {
/// False for an app's job that, once disabled, would leave the list at the next restart: launchd keeps only its
/// label, which neither starts with its app's identifier nor is declared in its app's bundle.
public var staysListedWhenDisabled = true
+ /// True for a job launchd runs from a file no longer on disk, removed while it was loaded: launchd forgets it at
+ /// the next logout or restart, and nothing loads it again.
+ public var isFileGone = false
public var isOwnerInstalled: Bool { ownerURL != nil }
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
index 46afa547..9bb640e7 100644
--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
@@ -339,6 +339,7 @@ public enum BackgroundItems {
item.runsFromTheTrash = programIsUnnamed && running.map { AppInspector.isInATrash(URL(filePath: $0)) } == true
item.isSystemExtension = program.map { PathComponents.isPath($0, inside: "/Library/SystemExtensions") } == true
item.isManagedByServiceManagement = details.managedBy == serviceManagement
+ item.isFileGone = !isAnApps && path?.isMissing == true
if isAnApps, item.canBeControlled, !item.isManagedByServiceManagement {
item.staysListedWhenDisabled =
ownership.owner(label: candidate.label, associated: [], program: nil)?.isInstalled == true
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
index d98e18ba..0c33787d 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
@@ -146,6 +146,27 @@ struct BackgroundItemActionsTests {
#expect(disabled.first { $0.label == "org.example.tide.other" }.map { $0.runsAtLoad == nil && $0.keepsAlive == nil } == true)
}
+ @Test func aJobWhoseFileIsGoneSaysSo() throws {
+ let directory = try TemporaryDirectory()
+ let job = try PropertyListSerialization.data(
+ fromPropertyList: ["Label": "org.example.tide.agent", "Program": "/bin/cat"], format: .xml, options: 0
+ )
+ let elsewhere = try directory.file("Elsewhere/org.example.tide.agent.plist", contents: job)
+ let gone = directory.url.appending(path: "Library/LaunchAgents/org.example.tide.gone.plist")
+ func item(_ label: String, loadedFrom file: URL) throws -> BackgroundItem {
+ let found = BackgroundItems.undeclaredItem(
+ (label, .agent, "gui/501/\(label)"),
+ answer: .details(Launchctl.JobDetails(path: file.path(percentEncoded: false), program: "/bin/cat")),
+ ownership: BackgroundItemOwnership(installedApps: []), loaded: .init(), exclusions: .none
+ )
+ guard case .item(let item) = found else { throw CocoaError(.featureUnsupported) }
+ return item
+ }
+
+ #expect(try item("org.example.tide.gone", loadedFrom: gone).isFileGone)
+ #expect(try !item("org.example.tide.agent", loadedFrom: elsewhere).isFileGone)
+ }
+
@Test func aSystemExtensionsJobIsLeftToSystemSettings() throws {
let label = "NetworkExtension.org.example.tide.network-extension.1.0.42"
let printed = """
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index cee02ddc..f713e385 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -151,7 +151,17 @@ struct BackgroundItemDetailView: View {
}
}
- if item.source == .otherFile {
+ if item.isFileGone {
+ Section {
+ Notice(
+ title: Text("Its file is gone"),
+ detail: item.kind == .daemon
+ ? Text("Its file was removed while it was loaded, so macOS runs it until the Mac restarts and nothing starts it again. Stop takes it out now.")
+ : Text("Its file was removed while it was loaded, so macOS runs it until you log out and nothing starts it again. Stop takes it out now."),
+ kind: .note
+ ) {}
+ }
+ } else if item.source == .otherFile {
Section {
Notice(
title: Text("Loaded from a file elsewhere"),
@@ -248,7 +258,7 @@ struct BackgroundItemDetailView: View {
}
private var finderURL: URL? {
- item.plistURL ?? item.program.map { URL(filePath: $0) }
+ (item.isFileGone ? nil : item.plistURL) ?? item.program.map { URL(filePath: $0) }
}
private var isBusy: Bool {
@@ -336,12 +346,15 @@ struct BackgroundItemDetailView: View {
/// Start, Stop, Enable, and Disable, which a job Peel may not control, a job whose state Peel could not read, a
/// file macOS can't load, and a job loaded from a file elsewhere don't have. Disabled, that last one would leave
- /// the list at the next logout or restart with nothing left to Enable it from. A job Peel may not disable has only
- /// Enable, while launchd keeps it disabled.
+ /// the list at the next logout or restart with nothing left to Enable it from. A job whose file is gone has only
+ /// Stop. A job Peel may not disable has only Enable, while launchd keeps it disabled.
private var hasOwnControls: Bool {
- guard item.canBeControlled, item.state != .unknown, item.source != .otherFile, !item.isUnreadable else {
+ guard item.canBeControlled, item.state != .unknown, item.source != .otherFile || item.isFileGone,
+ !item.isUnreadable
+ else {
return false
}
+ if item.isFileGone { return true }
if #available(macOS 27, *), item.isLeftByAGoneApp { return true }
return !item.isSeenOnlyWhileLoaded || item.isDisabled || item.mayBeDisabled
}
@@ -366,8 +379,12 @@ struct BackgroundItemDetailView: View {
private var ownControls: some View {
Group {
- // Stopping takes the job out of launchd, and nothing else removes one whose app is gone.
- if #available(macOS 27, *), item.isLeftByAGoneApp {
+ // Stopping takes the job out of launchd, and nothing else removes one whose file or app is gone.
+ if item.isFileGone {
+ Button("Stop", systemImage: "stop.fill") {
+ Task { await backgroundItems.perform(.stop, on: item) }
+ }
+ } else if #available(macOS 27, *), item.isLeftByAGoneApp {
Button("Remove", systemImage: "xmark.circle") {
Task { await backgroundItems.perform(.stop, on: item) }
}
diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swift
index 5d86469d..9fd076c7 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift
@@ -167,6 +167,11 @@ private struct BackgroundItemRow: View {
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(1)
+ } else if item.isFileGone {
+ StatusLabel(title: Text("Its file is gone"))
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .lineLimit(1)
} else if #available(macOS 27, *), item.runsFromTheTrash {
StatusLabel(title: Text("Runs from the Trash"))
.font(.caption)