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.

Stop calling an app's login item gone when launchctl doesn't name its program

Țugui Dragoșc7d87d23e553
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index c059f09a..9a7df65e 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -64205,6 +64205,112 @@
}
}
},
+ "Its app is in the Trash, and macOS starts it from there each time you log in, until you empty the Trash." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Položka leží v koši spolu se svou aplikací a systém macOS ji odtud při každém přihlášení spouští, dokud nevysypete koš."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Die zugehörige App ist im Papierkorb, und macOS startet dieses Objekt bei jeder Anmeldung von dort, bis du den Papierkorb entleerst."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Su app está en la papelera y macOS lo inicia desde ahí cada vez que inicias sesión, hasta que vacíes la papelera."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Son app est dans la corbeille, et macOS le lance depuis celle-ci à chaque ouverture de session, jusqu’à ce que vous vidiez la corbeille."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "La sua app è nel Cestino e macOS lo avvia da lì ogni volta che esegui il login, finché non svuoti il Cestino."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "これを追加したアプリはゴミ箱にあり、ゴミ箱を空にするまで、macOSはログインするたびにこれをゴミ箱から起動し続けます。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 항목의 앱이 휴지통에 있으며, 휴지통을 비울 때까지는 로그인할 때마다 macOS가 그곳에서 이 항목을 시작합니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "De bijbehorende app staat in de prullenmand, en macOS start het van daaruit telkens als je inlogt, totdat je de prullenmand leegt."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ta rzecz należy do aplikacji w Koszu, a macOS uruchamia ją stamtąd przy każdym logowaniu, dopóki nie opróżnisz Kosza."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O app dele está no Lixo, e o macOS o inicia a partir de lá sempre que você iniciar a sessão, até você esvaziar o Lixo."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aplicația sa este în Coș, iar macOS îl pornește de acolo la fiecare login, până când goliți Coșul."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Его приложение находится в Корзине, и macOS запускает его оттуда при каждом входе в систему, пока Вы не очистите Корзину."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Appen ligger i papperskorgen, och macOS startar det därifrån varje gång du loggar in, tills du tömmer papperskorgen."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Uygulaması Çöp Sepeti’nde ve Çöp Sepeti boşaltılana kadar macOS, her oturum açtığınızda bu öğeyi oradan başlatır."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Його програма в Смітнику, і macOS запускає його звідти щоразу, коли ви входите в систему, доки ви не очистите Смітник."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的App已在废纸篓中,macOS会在你每次登录时从那里启动它,直到你清倒废纸篓。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的App在「垃圾桶」中,而macOS會在你每次登入時從那裡啟動它,直到你清空「垃圾桶」。"
+ }
+ }
+ }
+ },
"Its command decodes base64, which keeps what it runs from being read at a glance. Software installed on purpose can do this too." : {
"localizations" : {
"cs" : {
@@ -132595,6 +132701,112 @@
}
}
},
+ "Runs from the Trash" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Běží z koše"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Läuft aus dem Papierkorb"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Se ejecuta desde la papelera"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "S’exécute depuis la corbeille"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "In esecuzione dal Cestino"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ゴミ箱から実行されます"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "휴지통에서 실행됨"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Actief vanuit de prullenmand"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Działa z Kosza"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Executado a partir do Lixo"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Rulează din Coș"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Запускается из Корзины"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Körs från papperskorgen"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Çöp Sepeti’nden çalışıyor"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Запускається зі Смітника"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "从废纸篓中运行"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "從「垃圾桶」執行"
+ }
+ }
+ }
+ },
"Rust Toolchains" : {
"localizations" : {
"cs" : {
@@ -153007,6 +153219,112 @@
}
}
},
+ "Take it out of launchd now. Its app is in the Trash, so macOS starts it again at the next login until you empty the Trash." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ihned odebrat úlohu z launchd. Její aplikace leží v koši, takže systém macOS úlohu při příštím přihlášení znovu spustí, dokud nevysypete koš."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Dieses Objekt jetzt aus launchd entfernen. Die zugehörige App ist im Papierkorb, daher startet macOS es ab der nächsten Anmeldung erneut, bis du den Papierkorb entleerst."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Quítalo de launchd ahora. Su app está en la papelera, así que macOS lo vuelve a iniciar la próxima vez que inicies sesión, hasta que vacíes la papelera."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Retirer maintenant cet élément de launchd. Son app est dans la corbeille : macOS le relancera donc dès la prochaine ouverture de session, jusqu’à ce que vous vidiez la corbeille."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Toglilo ora da launchd. La sua app è nel Cestino, quindi macOS lo avvia di nuovo al prossimo login, finché non svuoti il Cestino."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "今すぐlaunchdから取り除きます。これを追加したアプリはゴミ箱にあるため、ゴミ箱を空にするまでは、次回のログイン時にmacOSがこれを再び起動します。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "지금 launchd에서 제거하십시오. 이 항목의 앱이 휴지통에 있으므로, 휴지통을 비울 때까지는 다음 로그인 시 macOS가 이 항목을 다시 시작합니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Haal het nu uit launchd. De bijbehorende app staat in de prullenmand, dus macOS start het opnieuw de volgende keer dat je inlogt, totdat je de prullenmand leegt."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Usuń teraz tę rzecz z launchd. Należy ona do aplikacji w Koszu, więc macOS uruchamia ją ponownie przy kolejnym logowaniu, dopóki nie opróżnisz Kosza."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Retirar este item do launchd agora. O app dele está no Lixo, então o macOS vai iniciá-lo novamente na próxima vez que você iniciar a sessão, até você esvaziar o Lixo."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Scoateți‑l acum din launchd. Aplicația sa este în Coș, așa că macOS îl pornește din nou la următorul login până când goliți Coșul."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Убрать его из launchd сейчас. Его приложение находится в Корзине, поэтому macOS снова запустит его при следующем входе в систему, если Вы не очистите Корзину."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ta bort det ur launchd nu. Appen ligger i papperskorgen, så macOS startar det igen vid nästa inloggning tills du tömmer papperskorgen."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bunu şimdi launchd’den çıkar. Uygulaması Çöp Sepeti’nde, bu yüzden Çöp Sepeti boşaltılana kadar macOS, bir sonraki oturum açışınızda bu öğeyi yeniden başlatır."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Вилучити його з launchd зараз. Його програма в Смітнику, тож macOS знову запускатиме його під час кожного наступного входу в систему, доки ви не очистите Смітник."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "立即将此任务从launchd中移除。它的App已在废纸篓中,因此在你清倒废纸篓之前,macOS会在下次登录时再次启动它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "立即將它從launchd中移除。它的App在「垃圾桶」中,因此macOS會在下次登入時再次啟動它,直到你清空「垃圾桶」。"
+ }
+ }
+ }
+ },
"Take it out of launchd now: the app that added it is gone, and so is what it ran." : {
"localizations" : {
"cs" : {
@@ -153113,6 +153431,112 @@
}
}
},
+ "Take it out of launchd now: the app that added it is no longer installed." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ihned odebrat úlohu z launchd: aplikace, která ji přidala, už není nainstalována."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Dieses Objekt jetzt aus launchd entfernen: Die App, die es hinzugefügt hat, ist nicht mehr installiert."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Quítalo de launchd ahora: la app que lo añadió ya no está instalada."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Retirer maintenant cet élément de launchd : l’app qui l’a ajouté n’est plus installée."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Toglilo ora da launchd: l’app che l’ha aggiunto non è più installata."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "今すぐlaunchdから取り除きます。これを追加したアプリは現在はインストールされていません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "지금 launchd에서 제거하십시오. 이 항목을 추가한 앱이 더 이상 설치되어 있지 않습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Haal het nu uit launchd: de app die het heeft toegevoegd, is niet meer geïnstalleerd."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Usuń teraz tę rzecz z launchd: aplikacja, która ją dodała, nie jest już zainstalowana."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Retirar este item do launchd agora: o app que o adicionou não está mais instalado."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Scoateți‑l acum din launchd: aplicația care l‑a adăugat nu mai este instalată."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Убрать его из launchd сейчас: приложение, которое его добавило, больше не установлено."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ta bort det ur launchd nu: appen som lade till det är inte längre installerad."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bunu şimdi launchd’den çıkar: onu ekleyen uygulama artık yüklü değil."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Вилучити його з launchd зараз: програму, яка його додала, більше не інстальовано."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "立即将此任务从launchd中移除:添加它的App已不再安装。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "立即將它從launchd中移除:加入它的App已不再安裝。"
+ }
+ }
+ }
+ },
"Taken before a macOS update" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
index efa1f059..e3518bf8 100644
--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
@@ -50,12 +50,15 @@ public struct BackgroundItem: Sendable, Hashable, Identifiable {
/// True for an agent its file limits to the Background session, which launchd keeps in the user domain rather
/// than the GUI one: started, stopped and asked about there.
public var loadsInTheBackgroundSession = false
+ /// True while an app's job runs from inside a Trash: its app was moved there, and macOS starts it from there at
+ /// each login until the Trash is emptied.
+ public var runsFromTheTrash = false
public var isOwnerInstalled: Bool { ownerURL != nil }
- /// True for a job an app submitted that is still loaded after the app went, with nothing left to run: the app
- /// that would unregister it is gone, so only taking it out of launchd removes it.
- public var isLeftByAGoneApp: Bool { source == .app && !isOwnerInstalled && isOrphan }
+ /// True for a job an app submitted that is still loaded after the app went, its program gone or not named by
+ /// launchctl: the app that would unregister it is gone, so only taking it out of launchd removes it.
+ public var isLeftByAGoneApp: Bool { source == .app && !isOwnerInstalled && (isOrphan || program == nil) }
/// Includes the file's path, because two files can declare one label (a per-user copy beside the
/// system-wide one), and each file needs a row of its own.
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
index 9fe67f33..f52c078a 100644
--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
@@ -301,8 +301,12 @@ public enum BackgroundItems {
associated: job?.associated ?? [],
program: program
)
+ let state = loaded.state(of: candidate.label, candidate.kind)
+ // launchctl names no program for an app's login item or agent: macOS finds it in the app as it starts it.
+ let programIsUnnamed = isAnApps && program == nil
+ let running = if case .running(let pid) = state { RunningProgram.path(of: pid) } else { String?.none }
- return .item(BackgroundItem(
+ var item = BackgroundItem(
label: candidate.label,
kind: candidate.kind,
source: isAnApps ? .app : .otherFile,
@@ -313,12 +317,14 @@ public enum BackgroundItems {
ownerBundleIdentifier: owner?.bundleIdentifier,
ownerName: owner?.name,
ownerURL: owner?.url,
- isOrphan: ownership.isOrphan(label: candidate.label, program: program, owner: owner),
- state: loaded.state(of: candidate.label, candidate.kind),
+ isOrphan: !programIsUnnamed && ownership.isOrphan(label: candidate.label, program: program, owner: owner),
+ state: state,
isDisabled: loaded.override(of: candidate.label, candidate.kind) ?? false,
isOwnerConfirmed: owner?.isConfirmed ?? false,
unusualCommand: UnusualCommand(arguments: job?.arguments ?? program.map { [$0] } ?? [])
- ))
+ )
+ item.runsFromTheTrash = programIsUnnamed && running.map { AppInspector.isInATrash(URL(filePath: $0)) } == true
+ return .item(item)
}
private static func plists(in folder: URL) -> [URL] {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
index 48d30a4f..2cc5893d 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
@@ -26,20 +26,75 @@ struct BackgroundItemActionsTests {
#expect(try !#require(JobDefinition(["Label": "a"])).loadsOnlyInTheBackground)
}
- @Test func knowsAJobItsGoneAppLeftLoadedWithNothingToRun() {
- let job = { (source: BackgroundItem.Source, owner: URL?, isOrphan: Bool) in
+ @Test func knowsAJobItsGoneAppLeftLoaded() {
+ let job = { (source: BackgroundItem.Source, owner: URL?, isOrphan: Bool, program: String?) in
BackgroundItem(
- label: "org.example.helper", kind: .agent, source: source, plistURL: nil, program: nil,
+ label: "org.example.helper", kind: .agent, source: source, plistURL: nil, program: program,
runsAtLoad: false, keepsAlive: false, ownerBundleIdentifier: "org.example.app", ownerName: "Example",
ownerURL: owner, isOrphan: isOrphan, state: .loaded, isDisabled: false
)
}
let installed = URL(filePath: "/Applications/Example.app", directoryHint: .isDirectory)
+ let gone = "/Applications/Example.app/Contents/MacOS/helper"
- #expect(job(.app, nil, true).isLeftByAGoneApp)
- #expect(!job(.app, installed, false).isLeftByAGoneApp)
- #expect(!job(.app, nil, false).isLeftByAGoneApp)
- #expect(!job(.userLibrary, nil, true).isLeftByAGoneApp)
+ #expect(job(.app, nil, true, gone).isLeftByAGoneApp)
+ #expect(job(.app, nil, false, nil).isLeftByAGoneApp)
+ #expect(!job(.app, installed, false, nil).isLeftByAGoneApp)
+ #expect(!job(.app, nil, false, "/bin/sh").isLeftByAGoneApp)
+ #expect(!job(.userLibrary, nil, true, gone).isLeftByAGoneApp)
+ }
+
+ @Test func anAppsJobWhoseProgramLaunchctlLeavesOutIsNeverCalledOrphaned() throws {
+ let directory = try TemporaryDirectory()
+ let helper = "Tide.app/Contents/Library/LoginItems/TideHelper.app/Contents/MacOS/TideHelper"
+ let inTheTrash = try directory.runningProgram("home/.Trash/\(helper)")
+ defer { inTheTrash.terminate() }
+ let inPlace = try directory.runningProgram("home/Applications/\(helper)")
+ defer { inPlace.terminate() }
+ let registered = Launchctl.JobDetails(
+ path: "(submitted by smd.341)", managedBy: "com.apple.xpc.ServiceManagement",
+ parentBundleIdentifier: "org.example.tide"
+ )
+ func item(_ details: Launchctl.JobDetails, running pid: Int32?) throws -> BackgroundItem {
+ let found = BackgroundItems.undeclaredItem(
+ ("org.example.tide.helper", .agent, "gui/501/org.example.tide.helper"),
+ answer: .details(details),
+ ownership: BackgroundItemOwnership(installedApps: []),
+ loaded: .init(user: ["org.example.tide.helper": pid]),
+ exclusions: .none
+ )
+ guard case .item(let item) = found else { throw CocoaError(.featureUnsupported) }
+ return item
+ }
+
+ let fromTheTrash = try item(registered, running: inTheTrash.processIdentifier)
+ #expect(fromTheTrash.runsFromTheTrash)
+ #expect(!fromTheTrash.isOrphan)
+ #expect(fromTheTrash.isLeftByAGoneApp)
+
+ let stopped = try item(registered, running: nil)
+ #expect(!stopped.runsFromTheTrash)
+ #expect(!stopped.isOrphan)
+ #expect(stopped.isLeftByAGoneApp)
+
+ let elsewhere = try item(registered, running: inPlace.processIdentifier)
+ #expect(!elsewhere.runsFromTheTrash)
+ #expect(!elsewhere.isOrphan)
+
+ var named = registered
+ named.program = "/Applications/Tide.app/Contents/MacOS/org.example.tide.gone"
+ let goneProgram = try item(named, running: nil)
+ #expect(goneProgram.isOrphan)
+ #expect(goneProgram.isLeftByAGoneApp)
+
+ let trashedProgram = try #require(RunningProgram.path(of: inTheTrash.processIdentifier))
+ named.program = trashedProgram
+ #expect(try !item(named, running: inTheTrash.processIdentifier).runsFromTheTrash)
+
+ named.program = "/bin/sh"
+ let present = try item(named, running: nil)
+ #expect(!present.isOrphan)
+ #expect(!present.isLeftByAGoneApp)
}
@Test func aDisabledJobLaunchdDoesNotHaveIsEnabledFirst() {
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index ecafdc8a..d8fc73d2 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -35,7 +35,11 @@ struct BackgroundItemDetailView: View {
LabeledContent("Added by") {
VStack(alignment: .trailing, spacing: 1) {
Text(verbatim: item.ownerName ?? library.name(forReference: owner))
- if !item.isOwnerInstalled {
+ if #available(macOS 27, *), item.runsFromTheTrash {
+ Text("In the Trash")
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ } else if !item.isOwnerInstalled {
Text("No longer installed")
.font(.caption)
.foregroundStyle(.secondary)
@@ -253,6 +257,13 @@ struct BackgroundItemDetailView: View {
detail: Text("The program it starts is gone, and no installed app claims it.")
)
}
+ if #available(macOS 27, *), item.runsFromTheTrash {
+ NoteBadge(
+ title: Text("Runs from the Trash"), systemImage: "trash", tint: .orange,
+ name: String(localized: "Runs from the Trash"),
+ detail: Text("Its app is in the Trash, and macOS starts it from there each time you log in, until you empty the Trash.")
+ )
+ }
if let unusual = item.unusualCommand {
NoteBadge(
title: Text("Unusual command"), systemImage: "exclamationmark.magnifyingglass",
@@ -316,7 +327,7 @@ struct BackgroundItemDetailView: View {
Button("Remove", systemImage: "xmark.circle") {
Task { await backgroundItems.perform(.stop, on: item) }
}
- .help(Text("Take it out of launchd now: the app that added it is gone, and so is what it ran."))
+ .help(removeHelp)
} else {
// No Start or Stop for a job Peel sees only while it is loaded: once stopped it would leave the list,
// and Peel could not start it again. For an app's job, System Settings also offers only a switch.
@@ -334,6 +345,16 @@ struct BackgroundItemDetailView: View {
.disabled(isBusy || item.requiresPrivileges && !helper.canAct)
}
+ /// Why Remove is offered, as far as Peel knows where the job's program is.
+ private var removeHelp: Text {
+ if item.runsFromTheTrash {
+ return Text("Take it out of launchd now. Its app is in the Trash, so macOS starts it again at the next login until you empty the Trash.")
+ }
+ return item.isOrphan
+ ? Text("Take it out of launchd now: the app that added it is gone, and so is what it ran.")
+ : Text("Take it out of launchd now: the app that added it is no longer installed.")
+ }
+
@ViewBuilder
private var fileControls: some View {
if let finderURL {
diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swift
index fdd8936a..ec078cbb 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift
@@ -166,6 +166,11 @@ private struct BackgroundItemRow: View {
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(1)
+ } else if #available(macOS 27, *), item.runsFromTheTrash {
+ StatusLabel(title: Text("Runs from the Trash"))
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .lineLimit(1)
} else if item.isOrphan {
StatusLabel(title: Text("Nothing left to run"))
.font(.caption)