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
Background Items offers no control the helper would refuse
Țugui Dragoș4492176e0d7f
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swiftindex d192b6f8..b94f8147 100644--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift@@ -68,6 +68,12 @@ public struct BackgroundItem: Sendable, Hashable, Identifiable {declaresAnAppleLabel || SystemDaemons.shipped.contains(label) || SystemAgents.shipped.contains(label)}+ /// True when Peel may start, stop, enable and disable the job: never under a label of macOS, and a daemon only+ /// under a label the helper takes, which also leaves out the helper itself.+ public var canBeControlled: Bool {+ !usesALabelOfMacOS && (!requiresPrivileges || PrivilegedPathPolicy.allowsDaemon(label))+ }+public var removalRequiresPrivileges: Bool { source == .systemLibrary }/// True for a job Peel sees only while it is loaded, so once stopped it would leave the list and could not bediff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swiftindex 76898b02..ca67c3db 100644--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItemActions.swift@@ -18,7 +18,7 @@ public enum BackgroundItemActions {/// would reach macOS's own job. The helper refuses one for a daemon, and the same answer holds here for an/// agent, which `launchctl` runs without the helper.static func refusal(for item: BackgroundItem) -> Failure? {- item.usesALabelOfMacOS ? .launchctl(HelperRefusal.invalidRequest.rawValue) : nil+ item.canBeControlled ? nil : .launchctl(HelperRefusal.invalidRequest.rawValue)}@concurrentdiff --git a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swiftindex 23a2ae0b..708a8c4d 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift@@ -45,6 +45,26 @@ struct BackgroundItemActionsTests {#expect(BackgroundItemActions.refusal(for: agent("com.example.agent")) == nil)}+ @Test func controlsADaemonOnlyUnderALabelTheHelperTakes() {+ func job(_ label: String, _ kind: BackgroundItem.Kind) -> BackgroundItem {+ BackgroundItem(+ label: label, kind: kind, source: .systemLibrary, plistURL: nil, program: nil,+ runsAtLoad: false, keepsAlive: false, ownerBundleIdentifier: nil, ownerName: nil,+ isOwnerInstalled: false, isOrphan: false, state: .loaded, isDisabled: false+ )+ }++ #expect(job("org.example.daemon", .daemon).canBeControlled)+ #expect(!job("org.example.a daemon", .daemon).canBeControlled)+ #expect(!job("-org.example.daemon", .daemon).canBeControlled)+ #expect(!job(HelperIdentity.helperIdentifier, .daemon).canBeControlled)+ #expect(!job("com.openssh.sshd", .daemon).canBeControlled)+ #expect(BackgroundItemActions.refusal(for: job("org.example.a daemon", .daemon)) != nil)++ #expect(job("org.example.an agent", .agent).canBeControlled, "`launchctl` runs an agent without the helper")+ #expect(!job("com.apple.Finder.helper", .agent).canBeControlled)+ }+private func item(_ source: BackgroundItem.Source, state: BackgroundItem.State, plist: URL?) -> BackgroundItem {BackgroundItem(label: "com.example.agent", kind: source == .systemLibrary ? .daemon : .agent, source: source,diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swiftindex 11bf2748..cf3b6277 100644--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift@@ -186,7 +186,11 @@ struct BackgroundItemDetailView: View {}Button("Cancel", role: .cancel) {}} message: {- Text("Once the file is in the Trash, the item is stopped.")+ if item.canBeControlled || item.state == .notLoaded {+ Text("Once the file is in the Trash, the item is stopped.")+ } else {+ Text("macOS won’t start it again: it stops for good when the Mac restarts.")+ }}}@@ -290,13 +294,11 @@ struct BackgroundItemDetailView: View {.contentTransition(.opacity)}- /// Start, Stop, Enable, and Disable, which Peel's own helper, a job under one of macOS's labels, 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.+ /// 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.private var hasOwnControls: Bool {- !item.isPeelsHelper && !item.usesALabelOfMacOS && item.state != .unknown && item.source != .otherFile- && !item.isUnreadable+ item.canBeControlled && item.state != .unknown && item.source != .otherFile && !item.isUnreadable}private var controls: some View {