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
Ask to enable a disabled background job before starting it
Țugui Dragoșeeadcff44cf2
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 4423f8a6..6722954e 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -193079,6 +193079,112 @@}}},+ "macOS won’t load this while it is disabled. Enable it first, then start it." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Systém macOS tuto položku nenačte, dokud je vypnutá. Nejprve ji zapněte, potom ji spusťte."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS lädt dieses Objekt nicht, solange es deaktiviert ist. Aktiviere es zuerst und starte es dann."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS no cargará esto mientras esté desactivado. Actívalo primero y después inícialo."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS refuse de charger cet élément tant qu’il est désactivé. Activez-le d’abord, puis démarrez-le."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS non lo carica finché è disabilitato. Prima abilitalo, poi avvialo."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOSはこれを読み込みません。無効になっているためです。先に有効にしてから、開始してください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "이 항목이 비활성화되어 있는 동안에는 macOS가 로드하지 않습니다. 먼저 활성화한 다음 시작하십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS laadt dit niet zolang het is uitgeschakeld. Schakel het eerst in en start het daarna."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS nie wczyta tej rzeczy, dopóki jest wyłączona. Najpierw ją włącz, a potem uruchom."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O macOS não carrega isto enquanto estiver desativado. Ative-o primeiro e depois inicie-o."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS nu încarcă acest articol cât timp este dezactivat. Activați‑l mai întâi, apoi porniți‑l."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS не загрузит этот объект, пока он выключен. Сначала включите его, затем запустите."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS läser inte in det här så länge det är avaktiverat. Aktivera det först och starta det sedan."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS bunu etkin değilken yüklemez. Önce etkinleştirin, sonra başlatın."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS не завантажить цей елемент, поки його вимкнено. Спершу увімкніть його, а потім запустіть."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS不会在此项停用期间载入它。请先“启用”此项,然后再“启动”它。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS不會在此項目停用時載入它。請先啟用它,然後再啟動它。"+ }+ }+ }+ },"macOS won’t load this: its configuration file carries the mark macOS puts on downloads. Reinstalling the app that put it there may write it again without the mark." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swiftindex 75d7b553..d08ea3ee 100644--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift@@ -12,6 +12,8 @@ public enum BackgroundItemActions {/// On macOS 27 and later, launchd refuses to load a job whose property list carries the quarantine mark/// that macOS puts on downloads.case quarantinedPlist+ /// launchd does not load a job that is disabled (`bootstrap` answers error 5), so it is enabled first.+ case disabled}/// Why Peel will not start, stop or switch `item`, or nil. These go by label, so a label macOS itself uses@@ -39,6 +41,7 @@ public enum BackgroundItemActions {/// The job's file carries the quarantine mark, so launchd on macOS 27 and later would refuse to load it./// A job that is already loaded is still started with `kickstart`.case blockedByQuarantine+ case needsEnabling}static func plan(@@ -46,6 +49,7 @@ public enum BackgroundItemActions {isRefusedByLaunchd: (URL) -> Bool = Quarantine.stopsLaunchd) -> Start {guard item.state == .notLoaded, let plist = item.plistURL else { return .kickstart }+ if item.isDisabled { return .needsEnabling }return isRefusedByLaunchd(plist) ? .blockedByQuarantine : .bootstrap(plist)}@@ -55,6 +59,8 @@ public enum BackgroundItemActions {switch plan(toStart: item) {case .blockedByQuarantine:throw .quarantinedPlist+ case .needsEnabling:+ throw .disabledcase .bootstrap(let plist):if item.requiresPrivileges {try await runPrivileged(.bootstrap, for: item)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swiftindex 5296c282..956eae42 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift@@ -26,6 +26,19 @@ struct BackgroundItemActionsTests {#expect(try !#require(JobDefinition(["Label": "a"])).loadsOnlyInTheBackground)}+ @Test func aDisabledJobLaunchdDoesNotHaveIsEnabledFirst() {+ let plist = URL(filePath: "/Users/x/Library/LaunchAgents/com.example.agent.plist")+ let disabled = BackgroundItem(+ label: "com.example.agent", kind: .agent, source: .userLibrary, plistURL: plist, program: nil,+ runsAtLoad: false, keepsAlive: false, ownerBundleIdentifier: nil, ownerName: nil,+ ownerURL: nil, isOrphan: false, state: .notLoaded, isDisabled: true+ )++ #expect(BackgroundItemActions.plan(toStart: disabled, isRefusedByLaunchd: { _ in false }) == .needsEnabling)+ let enabled = item(state: .notLoaded, plist: plist)+ #expect(BackgroundItemActions.plan(toStart: enabled, isRefusedByLaunchd: { _ in false }) == .bootstrap(plist))+ }+/// On macOS 27 a job whose file carries a download's quarantine mark cannot be loaded. A job launchd already/// holds is still woken, marked or not.@Test func theMarkOfADownloadStopsALoadAndNothingElse() {diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swiftindex 420aa6c3..f489cb4c 100644--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift@@ -113,6 +113,7 @@ struct BackgroundItemList: View {case .noFileToMove: Text("This one comes from the app itself, so there is no file to move. Remove the app to get rid of it.")case .launchctl(let output): Text(verbatim: FixedSentence.translated(output))case .trash(let reason): Text(verbatim: reason.explanation)+ case .disabled: Text("macOS won’t load this while it is disabled. Enable it first, then start it.")case .quarantinedPlist: Text("macOS won’t load this: its configuration file carries the mark macOS puts on downloads. Reinstalling the app that put it there may write it again without the mark.")case nil: Text(verbatim: "")}