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
Offer each background item the buttons its state calls for
Țugui Dragoș6c5fc8fcf271
diff --git a/GUIDE.md b/GUIDE.mdindex ab48817e..a8b36504 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -285,8 +285,9 @@ and how many items the others hold.> Vulnerabilities, for a short explanation in plain words. Next to a file, it tells you why Peel thinks the file> belongs to the app.-- **Background Items:** launch agents and daemons, and the app that added each one, to start or stop, enable or- disable, show in Finder, or move to the Trash, through Peel's helper for those that run as root. One whose program+- **Background Items:** launch agents and daemons, and the app that added each one, to stop or restart while it runs,+ run now or unload while it waits for its time, load, enable or disable, show in Finder, or move to the Trash,+ through Peel's helper for those that run as root. One whose programis gone, or whose command looks unusual, says so. Remove takes out a job a deleted app left loaded,and an item whose app is in the Trash says that macOS starts it from there each time you log in, until you emptythe Trash. A job an app gave launchd itself, such as an update's installer, says so. Edit… beside an agent's file indiff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 1e729922..3135f7f0 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -92082,6 +92082,112 @@}}},+ "Load" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Načíst"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Laden"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Cargar"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Charger"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Carica"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "読み込む"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "로드"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Laad"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Wczytaj"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Carregar"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Încărcați"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Загрузить"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Läs in"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Yükle"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Завантажити"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "载入"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "載入"+ }+ }+ }+ },"Loaded" : {"localizations" : {"cs" : {@@ -166274,6 +166380,112 @@}}},+ "Restart" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Restartovat"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Neu starten"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Reiniciar"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Redémarrer"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Riavvia"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "再起動"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "재시동"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Herstart"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Uruchom ponownie"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Reiniciar"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Reporniți"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Перезапустить"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Starta om"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Yeniden Başlat"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Перезапустити"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "重新启动"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "重新啟動"+ }+ }+ }+ },"Restart your Mac and empty the Trash to finish." : {"localizations" : {"cs" : {@@ -167546,6 +167758,112 @@}}},+ "Run Now" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Spustit teď"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Jetzt ausführen"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ejecutar ahora"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Exécuter maintenant"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Esegui ora"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "今すぐ実行"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "지금 실행"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Voer nu uit"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Uruchom teraz"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Executar Agora"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Rulați acum"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Запустить сейчас"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kör nu"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Şimdi Çalıştır"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Запустити зараз"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "立即运行"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "立即執行"+ }+ }+ }+ },"Run the command in Terminal to use `peel` from anywhere, then type `peel --help` to see what it can do." : {"localizations" : {"cs" : {@@ -187144,112 +187462,6 @@}}},- "Start" : {- "localizations" : {- "cs" : {- "stringUnit" : {- "state" : "translated",- "value" : "Spustit"- }- },- "de" : {- "stringUnit" : {- "state" : "translated",- "value" : "Starten"- }- },- "es" : {- "stringUnit" : {- "state" : "translated",- "value" : "Iniciar"- }- },- "fr" : {- "stringUnit" : {- "state" : "translated",- "value" : "Démarrer"- }- },- "it" : {- "stringUnit" : {- "state" : "translated",- "value" : "Avvia"- }- },- "ja" : {- "stringUnit" : {- "state" : "translated",- "value" : "開始"- }- },- "ko" : {- "stringUnit" : {- "state" : "translated",- "value" : "시작"- }- },- "nl" : {- "stringUnit" : {- "state" : "translated",- "value" : "Start"- }- },- "pl" : {- "stringUnit" : {- "state" : "translated",- "value" : "Uruchom"- }- },- "pt" : {- "stringUnit" : {- "state" : "translated",- "value" : "Iniciar"- }- },- "ro" : {- "stringUnit" : {- "state" : "translated",- "value" : "Porniți"- }- },- "ru" : {- "stringUnit" : {- "state" : "translated",- "value" : "Запустить"- }- },- "sv" : {- "stringUnit" : {- "state" : "translated",- "value" : "Starta"- }- },- "tr" : {- "stringUnit" : {- "state" : "translated",- "value" : "Başlat"- }- },- "uk" : {- "stringUnit" : {- "state" : "translated",- "value" : "Запустити"- }- },- "zh-Hans" : {- "stringUnit" : {- "state" : "translated",- "value" : "启动"- }- },- "zh-Hant" : {- "stringUnit" : {- "state" : "translated",- "value" : "啟動"- }- }- }- },"Start Over" : {"localizations" : {"cs" : {@@ -190537,6 +190749,112 @@}}},+ "Stops it and starts it again at once." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Zastaví úlohu a hned ji znovu spustí."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Stoppt es und startet es sofort wieder."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Lo detiene y lo vuelve a iniciar al momento."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Arrête cet élément et le redémarre aussitôt."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Lo interrompe e lo avvia di nuovo subito."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "停止して、すぐに再び開始します。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "중단한 다음 즉시 다시 시작합니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Stopt het en start het meteen opnieuw."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Zatrzymuje tę rzecz i od razu uruchamia ją ponownie."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Interrompe o item e o inicia de novo imediatamente."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Îl oprește și îl pornește din nou imediat."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Останавливает его и сразу запускает снова."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Stoppar det och startar det igen direkt."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Onu durdurur ve hemen yeniden başlatır."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Зупиняє його й одразу запускає знову."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "将它停止,然后立即重新启动。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "將它停止,然後立即重新啟動。"+ }+ }+ }+ },"Storage" : {"localizations" : {"cs" : {@@ -220295,6 +220613,112 @@}}},+ "Unload" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Uvolnit"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Entladen"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Detener temporalmente"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Décharger"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Interrompi temporaneamente"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "読み込みを解除"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "로드 해제"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ontlaad"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Zwolnij"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Descarregar"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Opriți temporar"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Выгрузить"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ladda ur"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "launchd’den Çıkar"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Вивантажити"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "取消载入"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "卸載"+ }+ }+ }+ },"Unrated" : {"localizations" : {"cs" : {@@ -264971,6 +265395,112 @@}}},+ "“%@” couldn’t be loaded." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Položku „%@“ nelze načíst."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@“ konnte nicht geladen werden."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "No se ha podido cargar “%@”."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Impossible de charger « %@ »."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Impossibile caricare “%@”."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@”を読み込めませんでした。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "‘%@’을(를) 로드할 수 없습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "'%@' kon niet worden geladen."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nie udało się wczytać „%@”."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Não foi possível carregar “%@”."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@” nu a putut fi încărcat."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не удалось загрузить объект «%@»."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "”%@” kunde inte läsas in."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@” yüklenemedi."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не вдалося завантажити «%@»."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未能载入“%@”。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "無法載入「%@」。"+ }+ }+ }+ },"“%@” couldn’t be moved to the Trash." : {"localizations" : {"cs" : {@@ -265183,6 +265713,112 @@}}},+ "“%@” couldn’t be restarted." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Položku „%@“ nelze restartovat."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@“ konnte nicht neu gestartet werden."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "No se ha podido reiniciar “%@”."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Impossible de redémarrer « %@ »."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Impossibile riavviare “%@”."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@”を再起動できませんでした。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "‘%@’을(를) 재시동할 수 없습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "'%@' kon niet worden herstart."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nie udało się ponownie uruchomić „%@”."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Não foi possível reiniciar “%@”."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@” nu a putut fi repornit."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не удалось перезапустить объект «%@»."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "”%@” kunde inte startas om."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@” yeniden başlatılamadı."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не вдалося перезапустити «%@»."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未能重新启动“%@”。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "無法重新啟動「%@」。"+ }+ }+ }+ },"“%@” couldn’t be saved." : {"localizations" : {"cs" : {@@ -265501,6 +266137,112 @@}}},+ "“%@” couldn’t be unloaded." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Položku „%@“ nelze uvolnit."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@“ konnte nicht entladen werden."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "No se ha podido detener “%@”."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Impossible de décharger « %@ »."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Impossibile interrompere “%@”."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@”の読み込みを解除できませんでした。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "‘%@’을(를) 로드 해제할 수 없습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "'%@' kon niet worden ontladen."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nie udało się zwolnić „%@”."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Não foi possível descarregar “%@”."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„%@” nu a putut fi oprit."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не удалось выгрузить объект «%@»."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "”%@” kunde inte laddas ur."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%@” launchd’den çıkarılamadı."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не вдалося вивантажити «%@»."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未能取消载入“%@”。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "無法卸載「%@」。"+ }+ }+ }+ },"“%@” is enabled." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swiftindex 98ebf891..cfe24223 100644--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift@@ -175,21 +175,35 @@ public struct BackgroundItem: Sendable, Hashable, Identifiable {return !isSeenOnlyWhileLoaded || isDisabled || mayBeDisabled}- public enum StartOrStop: Sendable {- case start+ /// A button that changes whether the job runs, named for what it does to the state the page shows.+ public enum Control: Sendable, Hashable {+ /// Stops the job and takes it out of launchd.case stop+ /// Stops the running job and starts it again at once.+ case restart+ /// Starts the job now, whatever its schedule says.+ case runNow+ /// Takes the job, loaded and waiting for its time, out of launchd.+ case unload+ /// Loads the job from its file, after which macOS runs it as the file says.+ case load/// Stop under the name the page gives it for a job its gone app left loaded.case remove}- /// The one button that starts or stops the job, as launchd has it: Stop while launchd has it, running or waiting- /// for its time, and Start while it doesn't. A job Peel sees only while it is loaded has Stop only while it runs.- public var startOrStop: StartOrStop? {- guard offersControls else { return nil }- if canOnlyBeStopped { return .stop }- if isLeftByAGoneApp { return .remove }- if isSeenOnlyWhileLoaded { return isRunning ? .stop : nil }- return state == .notLoaded ? .start : .stop+ /// The buttons that change whether the job runs, in the order shown. A job Peel sees only while it is loaded has+ /// Stop only while it runs, and a disabled job that isn't loaded has none, since launchd refuses to load it.+ public var controls: [Control] {+ guard offersControls else { return [] }+ if canOnlyBeStopped { return [.stop] }+ if isLeftByAGoneApp { return [.remove] }+ if isSeenOnlyWhileLoaded { return isRunning ? [.stop] : [] }+ switch state {+ case .running: return [.stop, .restart]+ case .loaded: return [.runNow, .unload]+ case .notLoaded: return isDisabled ? [] : [.load]+ case .unknown: return []+ }}/// Enable and Disable, which a job Peel can only stop, and one its gone app left, don't have.diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swiftindex 495e03ba..0a762acb 100644--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift@@ -92,6 +92,17 @@ public enum BackgroundItemActions {}}+ /// Stops the running job and starts it again at once (`launchctl kickstart -k`).+ @concurrent+ public static func restart(_ item: BackgroundItem) async throws(Failure) {+ if let refusal = refusal(for: item) { throw refusal }+ if item.requiresPrivileges {+ try await runPrivileged(.restart, for: item)+ } else {+ try await run(["kickstart", "-k", target(of: item)])+ }+ }+/// Why Peel will not switch `item` on or off, or nil. Only System Settings turns off a job ServiceManagement/// manages, and a job whose row would leave the list once disabled is never disabled from here.static func refusal(toSwitch item: BackgroundItem, on isEnabled: Bool) -> Failure? {diff --git a/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift b/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swiftindex e2fc32b4..58609d00 100644--- a/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift+++ b/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift@@ -7,7 +7,7 @@ public enum HelperIdentity {public static let launchdPlistName = "com.tuguidragos.Peel.Helper.plist"/// Raise it whenever the helper changes, so Peel never works with a helper of another version. The helper/// refuses requests that carry any other version.- public static let protocolVersion = 19+ public static let protocolVersion = 20}/// The complete set of privileged operations. The helper validates every argument itself.@@ -54,6 +54,8 @@ public enum DaemonCommand: String, Sendable {case bootstrapcase bootoutcase kickstart+ /// `kickstart -k`: the running instance is ended first.+ case restartcase enablecase disable}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swiftindex 18cb8426..988b4ab3 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift@@ -135,12 +135,25 @@ struct BackgroundItemActionsTests {#expect(rows.map(\.canMoveToTrash) == [false, true])}- @Test func oneButtonStopsAJobLaunchdHasAndStartsOneItDoesNot() {+ @Test func eachStateOffersTheControlsThatChangeIt() {let file = URL(filePath: "/Users/me/Library/LaunchAgents/job.plist")- #expect(item(state: .running(pid: 42), plist: file).startOrStop == .stop)- #expect(item(state: .loaded, plist: file).startOrStop == .stop)- #expect(item(state: .notLoaded, plist: file).startOrStop == .start)- #expect(item(state: .unknown, plist: file).startOrStop == nil)+ #expect(item(state: .running(pid: 42), plist: file).controls == [.stop, .restart])+ #expect(item(state: .loaded, plist: file).controls == [.runNow, .unload])+ #expect(item(state: .notLoaded, plist: file).controls == [.load])+ #expect(item(state: .unknown, plist: file).controls.isEmpty)++ func disabled(_ state: BackgroundItem.State) -> BackgroundItem {+ BackgroundItem(+ label: "com.example.agent", kind: .agent, source: .userLibrary, plistURL: file, program: nil,+ runsAtLoad: false, keepsAlive: false, ownerBundleIdentifier: nil, ownerName: nil,+ ownerURL: nil, isOrphan: false, state: state, isDisabled: true+ )+ }+ // launchd refuses to load a disabled job, so only Enable is offered until it is enabled.+ #expect(disabled(.notLoaded).controls.isEmpty)+ #expect(disabled(.notLoaded).offersEnableOrDisable)+ #expect(disabled(.loaded).controls == [.runNow, .unload])+ #expect(disabled(.running(pid: 42)).controls == [.stop, .restart])var registered = BackgroundItem(label: "com.example.agent", kind: .agent, source: .app, plistURL: nil, program: "/Applications/App.app/x",@@ -148,29 +161,50 @@ struct BackgroundItemActionsTests {ownerURL: URL(filePath: "/Applications/App.app"), isOrphan: false, state: .running(pid: 42), isDisabled: false)registered.isManagedByServiceManagement = true- #expect(registered.startOrStop == .stop)+ #expect(registered.controls == [.stop])registered.state = .loaded- #expect(registered.startOrStop == nil)+ #expect(registered.controls.isEmpty)var elsewhere = item(state: .loaded, plist: URL(filePath: "/tmp/org.example.job.plist"))elsewhere.source = .otherFile- #expect(elsewhere.startOrStop == .stop)+ #expect(elsewhere.controls == [.stop])#expect(!elsewhere.offersEnableOrDisable)var left = item(state: .loaded, plist: nil)left.source = .appleft.isManagedByServiceManagement = true#expect(left.isLeftByAGoneApp)- #expect(left.startOrStop == .remove)+ #expect(left.controls == [.remove])#expect(!left.offersEnableOrDisable)var excluded = item(state: .running(pid: 42), plist: file)excluded.isExcluded = true- #expect(excluded.startOrStop == nil)+ #expect(excluded.controls.isEmpty)#expect(!excluded.offersEnableOrDisable)#expect(item(state: .loaded, plist: file).offersEnableOrDisable)}+ @Test func restartsOnlyAJobPeelMayControlAndAsksLaunchdToKillAndStartIt() async {+ var excluded = item(state: .running(pid: 42), plist: URL(filePath: "/Users/me/Library/LaunchAgents/job.plist"))+ excluded.isExcluded = true+ await #expect(throws: BackgroundItemActions.Failure.launchctl(HelperRefusal.invalidRequest.rawValue)) {+ try await BackgroundItemActions.restart(excluded)+ }++ // A made-up job launchd doesn't have: `kickstart -k` answers that it can't find it, and nothing else runs.+ let unknown = BackgroundItem(+ label: "org.example.never-loaded-\(UUID().uuidString)", kind: .agent, source: .userLibrary, plistURL: nil,+ program: nil, runsAtLoad: false, keepsAlive: false, ownerBundleIdentifier: nil, ownerName: nil,+ ownerURL: nil, isOrphan: false, state: .running(pid: 42), isDisabled: false+ )+ await #expect {+ try await BackgroundItemActions.restart(unknown)+ } throws: { error in+ guard case .launchctl(let output) = error as? BackgroundItemActions.Failure else { return false }+ return output.localizedCaseInsensitiveContains("could not find service")+ }+ }+@Test func startRunsALoadedJobAtOnceAndLoadsOneThatIsNot() {let file = URL(filePath: "/Users/me/Library/LaunchAgents/job.plist")diff --git a/Peel/Model/BackgroundItemLibrary.swift b/Peel/Model/BackgroundItemLibrary.swiftindex 68f6453a..e0c96c4f 100644--- a/Peel/Model/BackgroundItemLibrary.swift+++ b/Peel/Model/BackgroundItemLibrary.swift@@ -55,8 +55,9 @@ final class BackgroundItemLibrary {/// Starts, stops, enables or disables a job through launchd.private static func control(_ action: Action, _ item: BackgroundItem) async throws(BackgroundItemActions.Failure) {switch action {- case .start: try await BackgroundItemActions.start(item)- case .stop, .remove: try await BackgroundItemActions.stop(item)+ case .load, .runNow: try await BackgroundItemActions.start(item)+ case .stop, .unload, .remove: try await BackgroundItemActions.stop(item)+ case .restart: try await BackgroundItemActions.restart(item)case .enable: try await BackgroundItemActions.setEnabled(true, for: item)case .disable: try await BackgroundItemActions.setEnabled(false, for: item)case .moveToTrash: return@@ -127,8 +128,11 @@ final class BackgroundItemLibrary {}enum Action {- case start+ case load+ case runNowcase stop+ case unload+ case restart/// Stop under the name the page gives it for a job its gone app left loaded.case removecase enable@@ -211,7 +215,7 @@ final class BackgroundItemLibrary {var failed = falsedo {switch action {- case .start, .stop, .remove, .disable: try await control(action, item)+ case .load, .runNow, .stop, .unload, .restart, .remove, .disable: try await control(action, item)case .enable:try await control(action, item)noteEnabled(item)diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swiftindex b7ac3a4c..ba10c6e7 100644--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift@@ -443,7 +443,7 @@ struct BackgroundItemDetailView: View {private func ownControls(busyShown: Bool) -> some View {Group {- if let control = item.startOrStop {+ ForEach(item.controls, id: \.self) { control inButton(control.title) {Task { await backgroundItems.perform(control.action, on: item) }}@@ -464,25 +464,21 @@ struct BackgroundItemDetailView: View {.disabled(busyShown || item.requiresPrivileges && !helper.canAct)}- private func help(for control: BackgroundItem.StartOrStop) -> Text {+ private func help(for control: BackgroundItem.Control) -> Text {switch control {- case .start: startHelp+ case .load: Text("Loads it again, and macOS runs it when its file says to.")+ case .runNow: Text("Runs it now, whatever its schedule says.")+ case .restart: Text("Stops it and starts it again at once.")case .remove: removeHelpcase .stop where item.canOnlyBeStopped:item.isFileGone ? Text(verbatim: "") : Text("Takes it out of launchd. Its file stays where it is, and it runs again only if something loads it again.")case .stop where item.isSeenOnlyWhileLoaded:Text("Takes it out of launchd for now. It leaves this list until macOS or its app adds it again.")- case .stop:+ case .stop, .unload:Text("Takes it out of launchd until the next login or restart. Its file stays where it is.")}}- private var startHelp: Text {- item.startsAtOnce- ? Text("Runs it now, whatever its schedule says.")- : Text("Loads it again, and macOS runs it when its file says to.")- }-/// Why Remove is offered, as far as Peel knows where the job's program is.private var removeHelp: Text {if item.runsFromTheTrash {@@ -508,19 +504,25 @@ struct BackgroundItemDetailView: View {}-private extension BackgroundItem.StartOrStop {+private extension BackgroundItem.Control {var title: LocalizedStringKey {switch self {- case .start: "Start"case .stop: "Stop"+ case .restart: "Restart"+ case .runNow: "Run Now"+ case .unload: "Unload"+ case .load: "Load"case .remove: "Remove"}}var action: BackgroundItemLibrary.Action {switch self {- case .start: .startcase .stop: .stop+ case .restart: .restart+ case .runNow: .runNow+ case .unload: .unload+ case .load: .loadcase .remove: .remove}}diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swiftindex e6a437f7..bd206ca3 100644--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift@@ -154,8 +154,11 @@ struct BackgroundItemList: View {private func failureTitle(_ failure: BackgroundItemLibrary.ActionFailure) -> Text {let label = failure.labelreturn switch failure.action {- case .start: Text("“\(label)” couldn’t be started.")+ case .load: Text("“\(label)” couldn’t be loaded.")+ case .runNow: Text("“\(label)” couldn’t be started.")case .stop: Text("“\(label)” couldn’t be stopped.")+ case .unload: Text("“\(label)” couldn’t be unloaded.")+ case .restart: Text("“\(label)” couldn’t be restarted.")case .remove: Text("“\(label)” couldn’t be removed.")case .enable: Text("“\(label)” couldn’t be enabled.")case .disable: Text("“\(label)” couldn’t be disabled.")diff --git a/PeelHelper/HelperService.swift b/PeelHelper/HelperService.swiftindex 80de9464..2e56654c 100644--- a/PeelHelper/HelperService.swift+++ b/PeelHelper/HelperService.swift@@ -173,6 +173,7 @@ final class HelperService: NSObject, PeelHelperProtocol {case .bootstrap: ["bootstrap", "system", plists[0]]case .bootout: ["bootout", target]case .kickstart: ["kickstart", target]+ case .restart: ["kickstart", "-k", target]case .enable: ["enable", target]case .disable: ["disable", target]}diff --git a/PeelTests/BackgroundItemLibraryTests.swift b/PeelTests/BackgroundItemLibraryTests.swiftindex a3b5a59a..991e1291 100644--- a/PeelTests/BackgroundItemLibraryTests.swift+++ b/PeelTests/BackgroundItemLibraryTests.swift@@ -66,7 +66,7 @@ struct BackgroundItemLibraryTests {control: { _, _ in await held.run() })- let first = Task { await library.perform(.start, on: job) }+ let first = Task { await library.perform(.load, on: job) }for await _ in held.started { break }await library.perform(.stop, on: job)#expect(held.calls == 1)@@ -91,7 +91,7 @@ struct BackgroundItemLibraryTests {reads.library = libraryawait library.refresh(installedApps: [])- await library.perform(.start, on: job)+ await library.perform(.load, on: job)#expect(reads.wereShownAsAScan == [true, false])#expect(library.scans == 2)diff --git a/SAFETY.md b/SAFETY.mdindex 5c0e722b..dbabe0b2 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -269,7 +269,7 @@ Some of what Peel does is not a move to the Trash. Each is here with how it is u| An app that would not quit is force quit, only when you choose it | Can't be undone: what the app had not saved is lost || Remove Downloads frees this Mac's copy of a file in iCloud Drive | The file stays in iCloud and downloads again when you open it || Build Artifacts leaves a project's build folders out of Time Machine, when you ask it to | The same checkbox takes the mark off, and leaves alone a mark a tool put on what Peel never marks |-| A background item is stopped, started, disabled, or enabled | The same buttons in Background Items; a disabled item stays disabled after a restart until you enable it |+| A background item is stopped, restarted, run now, unloaded, loaded, disabled, or enabled | The same buttons in Background Items; a disabled item stays disabled after a restart until you enable it || A background job a deleted app left loaded is removed (`launchctl bootout`) | Nothing to bring back: its app, and what the job ran, are gone || An agent's file in your own `~/Library/LaunchAgents` is edited in Background Items, only when you save | Putting the file as it was back from History, which first moves your edit to the Trash, where History keeps it too || A tweak changes a setting of macOS, and the Dock, Finder, Control Center, or the window manager restarts to read it (`killall`, which for Finder stops anything it is copying) | Turning the tweak off puts back what was there before, or leaves it to macOS. Turn All Off puts back only what Peel changed, and leaves what you set yourself as it is |