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
Follow the icon style and accent color while Peel runs
Țugui Dragoșaff9960261db
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ee2a5fd4..2993454b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -762,6 +762,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.#### Every page+- Apps' icons follow the icon style chosen in System Settings > Appearance at once, as the Dock does: Peel kept the old+ style until it was opened again.- What VoiceOver hears as a list is read again waits for what it is saying: it cut off "Moved 1 item to the Trash"within a moment, and on Background Items an action's own scan no longer talks over the state it left.- On macOS 27, Uninstall with Peel in Finder's menu shows its mark in the color of the menu's text, where it was black on adiff --git a/Peel/Views/AboutView.swift b/Peel/Views/AboutView.swiftindex aa300980..6f175b52 100644--- a/Peel/Views/AboutView.swift+++ b/Peel/Views/AboutView.swift@@ -12,7 +12,8 @@ struct AboutContent: View {var body: some View {VStack(spacing: 12) {// IconServices draws the icon for the current appearance, so `id(colorScheme)` builds a new image- // when the appearance changes.+ // when the appearance changes, and reading the icon style builds one when that does.+ let _ = IconStyle.shared.revisionImage(nsImage: NSWorkspace.shared.icon(forFile: Bundle.main.bundlePath)).resizable().frame(width: 96, height: 96)diff --git a/Peel/Views/AppIcon.swift b/Peel/Views/AppIcon.swiftindex 6cb21133..8b0ee4d0 100644--- a/Peel/Views/AppIcon.swift+++ b/Peel/Views/AppIcon.swift@@ -16,6 +16,42 @@ struct AppIcon: View {}}+/// Tells what draws an icon that macOS now draws them differently. The icon style in System Settings > Appearance+/// changes every app's icon while Peel runs, and an image made earlier keeps the old one. macOS announces no change, so+/// this follows the settings it keeps the style in.+@Observable+final class IconStyle: NSObject {+ static let shared = IconStyle(defaults: .standard)++ /// The style itself, and the accent color, which a tinted style takes.+ private static let keys = ["AppleIconAppearanceTheme", "AppleAccentColor"]++ private(set) var revision = 0+ @ObservationIgnored private let defaults: UserDefaults++ init(defaults: UserDefaults) {+ self.defaults = defaults+ super.init()+ for key in Self.keys { defaults.addObserver(self, forKeyPath: key, context: nil) }+ }++ isolated deinit {+ for key in Self.keys { defaults.removeObserver(self, forKeyPath: key) }+ }++ nonisolated override func observeValue(+ forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?,+ context: UnsafeMutableRawPointer?+ ) {+ Task { @MainActor in self.changed() }+ }++ private func changed() {+ IconCache.forgetAll()+ revision += 1+ }+}+/// The icons rows draw. `NSWorkspace.icon(forFile:)` doesn't promise to cache and builds a new image each/// time, and rows ask for icons in `body`, on the main thread, so a list scrolled quickly would build the same/// icons again and again. `NSCache` holds them and lets them go when memory is short. Apps are held apart from@@ -46,6 +82,7 @@ enum IconCache {@MainActorstatic func icon(for url: URL) -> NSImage {+ _ = IconStyle.shared.revisionlet path = url.path(percentEncoded: false)if let image = images(for: url).object(forKey: path as NSString) { return image }let image = image(for: url)@@ -64,6 +101,12 @@ enum IconCache {}}+ @MainActor+ static func forgetAll() {+ apps.removeAllObjects()+ files.removeAllObjects()+ }+/// Icons are held by path, so once what was at a path is removed or replaced, its icon is let go.@MainActorstatic func forget(_ urls: some Sequence<URL>) {diff --git a/PeelTests/IconStyleTests.swift b/PeelTests/IconStyleTests.swiftnew file mode 100644index 00000000..80226b7e--- /dev/null+++ b/PeelTests/IconStyleTests.swift@@ -0,0 +1,21 @@+import AppKit+import Foundation+@testable import Peel+import Testing++@Suite(.serialized) struct IconStyleTests {+ @Test func iconsAreMadeAgainWhenTheIconStyleChanges() async throws {+ let made = try MadeUpDefaults()+ defer { made.forget() }+ let style = IconStyle(defaults: made.defaults)+ let app = URL(filePath: "/System/Applications/Calculator.app", directoryHint: .isDirectory)+ let earlier = IconCache.icon(for: app)+ #expect(IconCache.icon(for: app) === earlier)++ made.defaults.set("ClearLight", forKey: "AppleIconAppearanceTheme")+ for _ in 0..<10_000 where style.revision == 0 { await Task.yield() }++ #expect(style.revision > 0)+ #expect(IconCache.icon(for: app) !== earlier)+ }+}