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 to reopen Peel however Full Disk Access was turned on
Țugui Dragoșfd36633a8fee
diff --git a/Packages/PeelCore/Sources/PeelCore/Home/Access.swift b/Packages/PeelCore/Sources/PeelCore/Home/Access.swiftindex e80de356..5d672145 100644--- a/Packages/PeelCore/Sources/PeelCore/Home/Access.swift+++ b/Packages/PeelCore/Sources/PeelCore/Home/Access.swift@@ -41,6 +41,12 @@ public enum FullDiskAccess {return .granted}+ /// Whether Peel offers to reopen itself: Full Disk Access is still missing, and System Settings, where it is turned+ /// on, has been in front since Peel started. Access given there reaches only a process started after it.+ public static func offersReopen(_ state: AccessState, systemSettingsWasInFront: Bool) -> Bool {+ state == .missing && systemSettingsWasInFront+ }+public static let settingsURL = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles")!}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swiftindex dff11a6b..a8a71426 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomeTests.swift@@ -135,6 +135,13 @@ struct AccessTests {}/// Uses a folder of its own rather than `/Applications`, where write access depends on the account.+ @Test func offersToReopenOnceSystemSettingsWasInFront() {+ #expect(FullDiskAccess.offersReopen(.missing, systemSettingsWasInFront: true))+ #expect(!FullDiskAccess.offersReopen(.missing, systemSettingsWasInFront: false))+ #expect(!FullDiskAccess.offersReopen(.granted, systemSettingsWasInFront: true))+ #expect(!FullDiskAccess.offersReopen(.unknown, systemSettingsWasInFront: true))+ }+@Test func readsAppManagementFromARemoval() throws {let directory = try TemporaryDirectory()let bundle = try directory.directory("Applications/Example.app")diff --git a/Peel/Model/FrontmostApp.swift b/Peel/Model/FrontmostApp.swiftindex fbe366f4..13056b73 100644--- a/Peel/Model/FrontmostApp.swift+++ b/Peel/Model/FrontmostApp.swift@@ -9,16 +9,27 @@ final class FrontmostApp {static let shared = FrontmostApp()private(set) var bundleIdentifier = NSWorkspace.shared.frontmostApplication?.bundleIdentifier+ /// True once System Settings has been in front since Peel started, however the person got there.+ private(set) var hasShownSystemSettings = false- private init() {+ init(observing: Bool = true) {+ note(bundleIdentifier)+ guard observing else { return }NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didActivateApplicationNotification,object: nil,queue: .main- ) { note in+ ) { [weak self] note inlet identifier = (note.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication)?.bundleIdentifier- MainActor.assumeIsolated { FrontmostApp.shared.bundleIdentifier = identifier }+ MainActor.assumeIsolated { self?.note(identifier) }+ }+ }++ func note(_ identifier: String?) {+ bundleIdentifier = identifier+ if identifier == "com.apple.systempreferences" {+ hasShownSystemSettings = true}}}diff --git a/Peel/Model/HomeModel.swift b/Peel/Model/HomeModel.swiftindex 54c96b08..249cae1a 100644--- a/Peel/Model/HomeModel.swift+++ b/Peel/Model/HomeModel.swift@@ -100,7 +100,7 @@ final class HomeModel {/// False until the first check finishes. Until then no state is shown, so the panel never flashes a wrong one. The/// helper's row is checked apart and says so until its own answer.private(set) var hasChecked = false- private var hasOpenedFullDiskAccessSettings = false+ private let frontmost = FrontmostApp.sharedinit(helper: HelperModel) {self.helper = helper@@ -167,7 +167,9 @@ final class HomeModel {isFinderExtensionEnabled ? false : await Self.finderExtensionRunsFromAnotherCopy()let fullDisk = await access- needsRelaunchForFullDiskAccess = fullDisk == .missing && hasOpenedFullDiskAccessSettings+ needsRelaunchForFullDiskAccess = FullDiskAccess.offersReopen(+ fullDisk, systemSettingsWasInFront: frontmost.hasShownSystemSettings+ )let opensAtLogin = await LoginItem.status() == .enabledfound = [.fullDiskAccess: state(for: fullDisk),@@ -219,7 +221,6 @@ final class HomeModel {}func openFullDiskAccessSettings() {- hasOpenedFullDiskAccessSettings = trueNSWorkspace.shared.open(FullDiskAccess.settingsURL)}diff --git a/PeelTests/FrontmostAppTests.swift b/PeelTests/FrontmostAppTests.swiftnew file mode 100644index 00000000..2cb55215--- /dev/null+++ b/PeelTests/FrontmostAppTests.swift@@ -0,0 +1,18 @@+@testable import Peel+import Testing++@MainActor+struct FrontmostAppTests {+ @Test func remembersThatSystemSettingsWasInFront() {+ let frontmost = FrontmostApp(observing: false)++ frontmost.note("org.example.other")+ let before = frontmost.hasShownSystemSettings+ frontmost.note("com.apple.systempreferences")+ frontmost.note("org.example.other")++ #expect(!before)+ #expect(frontmost.hasShownSystemSettings)+ #expect(frontmost.bundleIdentifier == "org.example.other")+ }+}