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 that a job in a logged-in session stops when you log out

Țugui Dragoșa90527d6afed
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 52032a9c..cf5ba2d5 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -252365,6 +252365,112 @@
}
}
},
+ "macOS won’t start it again: it stops for good when you log out." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Systém macOS ji znovu nespustí: po odhlášení se trvale zastaví."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS startet es nicht erneut: Wenn du dich abmeldest, ist es endgültig gestoppt."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS no volverá a iniciarlo: se detendrá definitivamente cuando cierres sesión."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS ne le relancera plus : il s’arrêtera définitivement à la fermeture de votre session."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS non lo avvierà più: si interromperà definitivamente quando esegui il logout."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOSがこれを再び起動することはありません。ログアウトすると、完全に停止します。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS가 이 항목을 다시 시작하지 않습니다. 로그아웃하면 영구적으로 중단됩니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS start het niet opnieuw: het stopt definitief als je uitlogt."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS już go nie uruchomi: zatrzyma się na dobre, gdy się wylogujesz."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O macOS não vai iniciá-lo novamente: ele é interrompido definitivamente quando você finaliza a sessão."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS nu îl va mai porni: se oprește definitiv când faceți logout."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS больше не запустит этот объект: он окончательно остановится, когда Вы выйдете из системы."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS startar det inte igen: det stoppas för gott när du loggar ut."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS onu bir daha başlatmaz: oturumu kapattığınızda kalıcı olarak durur."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS не запускатиме його знову: він зупиниться назавжди, коли ви вийдете із системи."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS不会再次启动它:你退出登录后,它会永久停止。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS不會再啟動它:你登出後,它就會永久停止。"
+ }
+ }
+ }
+ },
"macOS’s menu bar items restart" : {
"localizations" : {
"cs" : {
diff --git a/Peel/Model/BackgroundItemLibrary.swift b/Peel/Model/BackgroundItemLibrary.swift
index a457c693..1d45a5df 100644
--- a/Peel/Model/BackgroundItemLibrary.swift
+++ b/Peel/Model/BackgroundItemLibrary.swift
@@ -107,6 +107,7 @@ final class BackgroundItemLibrary {
let reason: BackgroundItemActions.Failure
/// The job's file is in the Trash, and `reason` is why launchd still runs the job.
var fileMoved = false
+ var stopsForGood: LocalizedStringResource?
}
/// What the list says after an action: why it failed, or that an enabled job left the list until macOS loads it.
@@ -161,7 +162,10 @@ final class BackgroundItemLibrary {
alerts.add(.failed(failure))
}
if let reason = moved.stillRunning {
- let failure = ActionFailure(label: item.label, action: action, reason: reason, fileMoved: true)
+ let failure = ActionFailure(
+ label: item.label, action: action, reason: reason, fileMoved: true,
+ stopsForGood: item.stopsForGood
+ )
alerts.add(.failed(failure))
}
}
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index 0d51bb5b..d009e35e 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -204,9 +204,9 @@ struct BackgroundItemDetailView: View {
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."),
+ detail: item.endsAtLogout
+ ? 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.")
+ : 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."),
kind: .note
) {}
}
@@ -214,9 +214,9 @@ struct BackgroundItemDetailView: View {
Section {
Notice(
title: Text("Loaded from a file elsewhere"),
- detail: item.kind == .daemon
- ? Text("Something loaded this from a file outside the folders macOS reads at startup, so macOS forgets it when the Mac restarts. The file is shown above.")
- : Text("Something loaded this from a file outside the folders macOS reads at login, so macOS forgets it when you log out. The file is shown above."),
+ detail: item.endsAtLogout
+ ? Text("Something loaded this from a file outside the folders macOS reads at login, so macOS forgets it when you log out. The file is shown above.")
+ : Text("Something loaded this from a file outside the folders macOS reads at startup, so macOS forgets it when the Mac restarts. The file is shown above."),
kind: .note
) {}
}
@@ -529,12 +529,21 @@ extension BackgroundItem {
return "\(ownerName) uses it to run in the background, and may stop working until you put it back."
}
+ /// Whether launchd forgets the job as the person logs out: an agent's GUI domain ends then, while a daemon's system
+ /// domain and an agent's user domain stay (`man launchctl`).
+ var endsAtLogout: Bool { kind == .agent && !loadsInTheBackgroundSession }
+
+ /// What becomes of a job launchd still runs once its file is in the Trash.
+ var stopsForGood: LocalizedStringResource {
+ endsAtLogout
+ ? "macOS won’t start it again: it stops for good when you log out."
+ : "macOS won’t start it again: it stops for good when the Mac restarts."
+ }
+
/// What the question before a move says becomes of the job once its file is in the Trash. A row named by its file
/// has no label Peel read, so nothing is stopped for it.
var whenTrashed: LocalizedStringResource {
- guard canBeControlled && !isNamedByItsFile || state == .notLoaded else {
- return "macOS won’t start it again: it stops for good when the Mac restarts."
- }
+ guard canBeControlled && !isNamedByItsFile || state == .notLoaded else { return stopsForGood }
// An agent in `/Library/LaunchAgents` runs in every account logged in, and Stop reaches only this one.
return kind == .agent && source == .systemLibrary
? "Once the file is in the Trash, the item is stopped for you. Other accounts logged in now run it until they log out, and none starts it again."
diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swift
index 698c2dc4..e317ec7d 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift
@@ -151,8 +151,8 @@ struct BackgroundItemList: View {
private func failureMessage(_ failure: BackgroundItemLibrary.ActionFailure) -> Text {
let reason = reasonMessage(failure.reason)
- guard failure.fileMoved else { return reason }
- return Text("\(reason)\n\n\(Text("macOS won’t start it again: it stops for good when the Mac restarts."))")
+ guard let stopsForGood = failure.stopsForGood else { return reason }
+ return Text("\(reason)\n\n\(Text(stopsForGood))")
}
private func reasonMessage(_ reason: BackgroundItemActions.Failure) -> Text {
diff --git a/PeelTests/BackgroundItemTrashWordsTests.swift b/PeelTests/BackgroundItemTrashWordsTests.swift
index b36b6fc6..68afb853 100644
--- a/PeelTests/BackgroundItemTrashWordsTests.swift
+++ b/PeelTests/BackgroundItemTrashWordsTests.swift
@@ -17,12 +17,33 @@ struct BackgroundItemTrashWordsTests {
#expect(String(localized: job(.userLibrary).whenTrashed) == String(localized: "Once the file is in the Trash, the item is stopped."))
}
+ @Test func saysWhenAJobStillRunningEnds() {
+ var agent = job(.userLibrary)
+ agent.state = .unknown
+ var daemon = BackgroundItem(
+ label: "org.example.daemon", kind: .daemon, source: .systemLibrary,
+ plistURL: URL(filePath: "/x/org.example.daemon.plist"), program: "/usr/local/bin/daemon", runsAtLoad: true,
+ keepsAlive: false, ownerBundleIdentifier: nil, ownerName: nil, ownerURL: nil, isOrphan: false,
+ state: .unknown, isDisabled: false
+ )
+ daemon.isNamedByItsFile = true
+ agent.isNamedByItsFile = true
+ var inTheBackground = agent
+ inTheBackground.loadsInTheBackgroundSession = true
+ let atLogout = String(localized: "macOS won’t start it again: it stops for good when you log out.")
+ let atRestart = String(localized: "macOS won’t start it again: it stops for good when the Mac restarts.")
+
+ #expect(String(localized: agent.whenTrashed) == atLogout)
+ #expect(String(localized: daemon.whenTrashed) == atRestart)
+ #expect(String(localized: inTheBackground.whenTrashed) == atRestart)
+ }
+
@Test func promisesNoStopForARowNamedByItsFile() {
var named = job(.userLibrary)
named.state = .unknown
named.isClosedToPeel = true
named.isNamedByItsFile = true
- #expect(String(localized: named.whenTrashed) == String(localized: "macOS won’t start it again: it stops for good when the Mac restarts."))
+ #expect(String(localized: named.whenTrashed) == String(localized: "macOS won’t start it again: it stops for good when you log out."))
}
}