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
Tell once with a notification that a new version of Peel is out
Țugui Dragoș9365a6d70893
diff --git a/GUIDE.md b/GUIDE.mdindex 0f675c15..167bc080 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -245,7 +245,7 @@ and takes you straight to the right place in System Settings.| Full Disk Access | Look inside the Trash and the private folders where apps keep their data. Without it, Peel can't find everything an app leaves behind. || App Management | Move another developer's app to the Trash. Without it, Peel can still clear an app's files, but macOS may refuse to move the app itself. || Helper | Move the leftovers that sit in folders only an administrator can change, and put them back, and start, stop, enable, or disable other developers' background items that run as root. It answers administrators only. macOS asks you to approve it once in Login Items & Extensions, and an update of Peel brings its new helper with it. |-| Notifications (optional) | Tell you when your apps have updates, when Homebrew finishes an upgrade or runs into a problem, when your disk is almost full if you turn that warning on, and, with Watch the Trash on, when you move an app to the Trash yourself. |+| Notifications (optional) | Tell you when your apps have updates, when a new version of Peel is out, when Homebrew finishes an upgrade or runs into a problem, when your disk is almost full if you turn that warning on, and, with Watch the Trash on, when you move an app to the Trash yourself. || Folders macOS asks about | Without Full Disk Access, macOS asks the first time Peel looks in Desktop, Documents, or Downloads for installers, duplicates, and what builds left, inside another app's data for what it would leave behind, or at your cloud folders to measure them. || Finder extension (optional) | Add Uninstall with Peel to the menu you get when you Control-click an app in Finder. || Open at Login (optional) | Start Peel when you log in. With Show in Menu Bar on, it keeps running after you close its window, so Watch the Trash keeps working. |diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 3b023724..2309910c 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -26385,6 +26385,112 @@}}},+ "Click to download it in About, then replace this copy in Applications." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Klikněte a v okně O aplikaci Peel si stáhněte novou verzi. Pak jí nahraďte tuto kopii ve složce Aplikace."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Klicke, um die neue Version unter „Über ‚Peel‘“ zu laden, und ersetze dann diese Kopie im Ordner „Programme“."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Haz clic para descargarla desde Acerca de Peel y luego reemplaza esta copia en la carpeta Aplicaciones."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Cliquez pour le télécharger depuis « À propos de Peel », puis remplacez cette copie dans le dossier Applications."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Fai clic per scaricarla da “Informazioni su Peel”, poi sostituisci questa copia nella cartella Applicazioni."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "クリックすると、“Peelについて”でダウンロードできます。その後、“アプリケーション”フォルダにあるこのPeelを新しいバージョンに置き換えてください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "클릭하면 ‘Peel에 관하여’에서 다운로드할 수 있습니다. 그런 다음 응용 프로그램 폴더에서 이 복사본을 새로운 버전으로 대치하십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Klik om de nieuwe versie te downloaden via 'Over Peel' en vervang daarmee deze kopie in de map 'Apps'."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Kliknij, aby ją pobrać w oknie „O programie Peel”, a potem zastąp nią tę kopię w folderze Aplikacje."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Clique para baixar a nova versão em Sobre o App Peel e depois substitua esta cópia na pasta Aplicativos."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Faceți clic pentru a o descărca din fereastra Despre Peel, apoi înlocuiți cu ea această copie din dosarul Aplicații."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Нажмите, чтобы загрузить ее в окне «О приложении Peel», а затем замените эту копию в папке «Программы»."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Klicka för att hämta den i Om Peel. Ersätt sedan den här kopian i mappen Appar."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Yeni sürümü Peel Hakkında penceresinden indirmek için tıklayın, ardından Uygulamalar klasöründeki bu kopyayı yenisiyle değiştirin."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Натисніть, щоб викачати її у вікні «Про програму», а потім замініть нею цю копію в папці «Програми»."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "点按即可在“关于Peel”窗口中下载新版本,然后在“应用程序”文件夹中用它替换此Peel副本。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "按一下即可在「關於Peel」中下載新版本,然後用它取代「應用程式」檔案夾中的這份副本。"+ }+ }+ }+ },"Click to see what it left behind, under Applications." : {"localizations" : {"cs" : {@@ -51428,6 +51534,112 @@}}},+ "Homebrew installed this copy. Click to see the command that upgrades it, in About." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Tuto kopii nainstaloval Homebrew. Klikněte a v okně O aplikaci Peel uvidíte příkaz, který ji upgraduje."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew hat diese Kopie installiert. Klicke, um unter „Über ‚Peel‘“ den Befehl für das Upgrade zu sehen."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew instaló esta copia. Haz clic para ver el comando que la actualiza, en Acerca de Peel."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew a installé cette copie. Cliquez pour voir la commande qui la met à niveau, dans « À propos de Peel »."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Questa copia è stata installata da Homebrew. Fai clic per vedere il comando per aggiornarla, in “Informazioni su Peel”."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "このPeelはHomebrewでインストールされています。クリックすると、“Peelについて”で、アップグレード用のコマンドを確認できます。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew가 이 복사본을 설치했습니다. 클릭하면 ‘Peel에 관하여’에서 업그레이드 명령을 볼 수 있습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew heeft deze kopie geïnstalleerd. Klik om in 'Over Peel' het commando te zien waarmee je die upgradet."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Tę kopię zainstalował Homebrew. Kliknij, aby w oknie „O programie Peel” zobaczyć polecenie, które ją uaktualnia."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O Homebrew instalou esta cópia. Clique para ver o comando que faz upgrade dela, em Sobre o App Peel."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew a instalat această copie. Faceți clic pentru a vedea comanda care îi face upgrade, în fereastra Despre Peel."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Эту копию установил Homebrew. Нажмите, чтобы увидеть в окне «О приложении Peel» команду для ее обновления."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Homebrew installerade den här kopian. Klicka för att se kommandot som uppgraderar den, i Om Peel."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bu kopyayı Homebrew yükledi. Onu yükselten komutu Peel Hakkında penceresinde görmek için tıklayın."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Цю копію інсталював Homebrew. Натисніть, щоб побачити у вікні «Про програму» команду, яка її оновлює."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "此Peel副本由Homebrew安装。点按即可在“关于Peel”窗口中查看升级它的命令。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "這份副本是由Homebrew安裝的。按一下即可在「關於Peel」中查看升級它的指令。"+ }+ }+ }+ },"Homebrew installs command-line tools as formulae and apps as casks. On this page Peel only runs Homebrew’s own commands and reads what they report." : {"localizations" : {"cs" : {@@ -98756,6 +98968,112 @@"comment" : "The app's name, never translated.","shouldTranslate" : false},+ "Peel %@ is out" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Vyšel Peel %@"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ ist verfügbar"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ disponible"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ est disponible"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ disponibile"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@が公開されました"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ 출시됨"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ is verschenen"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Dostępna wersja Peel %@"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ disponível"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "A apărut Peel %@"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Вышла версия Peel %@"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ har släppts"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@ çıktı"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Вийшла Peel %@"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@已发布"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %@已推出"+ }+ }+ }+ },"Peel Inventory.%@" : {"comment" : "A suggested file name. Translate the words before the dot. %@ is the file extension, such as json.","localizations" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/NewerPeelNotice.swift b/Packages/PeelCore/Sources/PeelCore/Updates/NewerPeelNotice.swiftnew file mode 100644index 00000000..3fd1d0cf--- /dev/null+++ b/Packages/PeelCore/Sources/PeelCore/Updates/NewerPeelNotice.swift@@ -0,0 +1,13 @@+/// When Peel tells with a notification that a newer version of itself is out: once for each version.+public enum NewerPeelNotice {+ public struct Answer: Sendable, Hashable {+ public let tell: Bool+ /// The version told last, which the next check is given.+ public let told: String?+ }++ public static func check(newer: String?, told: String?) -> Answer {+ guard let newer, newer != told else { return Answer(tell: false, told: told) }+ return Answer(tell: true, told: newer)+ }+}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/NewerPeelNoticeTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/NewerPeelNoticeTests.swiftnew file mode 100644index 00000000..7d48ae0e--- /dev/null+++ b/Packages/PeelCore/Tests/PeelCoreTests/NewerPeelNoticeTests.swift@@ -0,0 +1,15 @@+@testable import PeelCore+import Testing++struct NewerPeelNoticeTests {+ @Test func tellsOnceForEachNewerVersion() {+ #expect(NewerPeelNotice.check(newer: nil, told: nil) == .init(tell: false, told: nil))+ #expect(NewerPeelNotice.check(newer: "1.0.2", told: nil) == .init(tell: true, told: "1.0.2"))+ #expect(NewerPeelNotice.check(newer: "1.0.2", told: "1.0.2") == .init(tell: false, told: "1.0.2"))+ #expect(NewerPeelNotice.check(newer: "1.0.3", told: "1.0.2") == .init(tell: true, told: "1.0.3"))+ }++ @Test func keepsWhatItToldOnceThisCopyIsUpToDate() {+ #expect(NewerPeelNotice.check(newer: nil, told: "1.0.3") == .init(tell: false, told: "1.0.3"))+ }+}diff --git a/Peel/Model/PeelNotifications.swift b/Peel/Model/PeelNotifications.swiftindex ff3f2a51..dc44486c 100644--- a/Peel/Model/PeelNotifications.swift+++ b/Peel/Model/PeelNotifications.swift@@ -8,6 +8,7 @@ import UserNotificationsfinal class PeelNotifications: NSObject, UNUserNotificationCenterDelegate {private nonisolated static let pathKey = "path"private nonisolated static let toolKey = "tool"+ private nonisolated static let aboutKey = "about"func activate() {UNUserNotificationCenter.current().delegate = self@@ -60,6 +61,18 @@ final class PeelNotifications: NSObject, UNUserNotificationCenterDelegate {UNUserNotificationCenter.current().add(request)}+ /// Tells once that a newer Peel is out. Peel never installs itself, so the notification leads to About.+ func notify(newerPeel update: AppLibrary.PeelUpdate) {+ let content = UNMutableNotificationContent()+ content.title = String(localized: "Peel \(update.version) is out")+ content.body = update.homebrewCommand == nil+ ? String(localized: "Click to download it in About, then replace this copy in Applications.")+ : String(localized: "Homebrew installed this copy. Click to see the command that upgrades it, in About.")+ content.userInfo = [Self.aboutKey: true]+ let request = UNNotificationRequest(identifier: "newer-peel", content: content, trigger: nil)+ UNUserNotificationCenter.current().add(request)+ }+func notify(diskNearlyFull storage: DeviceInfo.Storage) {let content = UNMutableNotificationContent()content.title = String(localized: "Your disk is almost full")@@ -80,6 +93,10 @@ final class PeelNotifications: NSObject, UNUserNotificationCenterDelegate {_ center: UNUserNotificationCenter,didReceive response: UNNotificationResponse) async {+ if response.notification.request.content.userInfo[Self.aboutKey] != nil {+ await MainActor.run { Navigator.shared.showAbout() }+ return+ }if let tool = response.notification.request.content.userInfo[Self.toolKey] as? String {await MainActor.run {if let tool = Tool(rawValue: tool) {diff --git a/Peel/Navigation/Navigator.swift b/Peel/Navigation/Navigator.swiftindex c1d91830..071481c1 100644--- a/Peel/Navigation/Navigator.swift+++ b/Peel/Navigation/Navigator.swift@@ -25,4 +25,10 @@ final class Navigator {openWindow?(id: PeelApp.mainWindowID)NSApp.activate()}++ /// Opens About, where a newer Peel is told with how to get it, and brings Peel forward.+ func showAbout() {+ openWindow?(id: AboutView.windowID)+ NSApp.activate()+ }}diff --git a/Peel/PeelApp.swift b/Peel/PeelApp.swiftindex 5830d407..32433cf3 100644--- a/Peel/PeelApp.swift+++ b/Peel/PeelApp.swift@@ -224,6 +224,22 @@ struct PeelApp: App {}}+ /// Tells once for each newer version of Peel, whichever check found it.+ private func followNewerPeel() async {+ for await _ in Observations({ library.newerPeel?.version }) {+ guard !Task.isCancelled else { return }+ let defaults = UserDefaults.standard+ let told = defaults.string(forKey: SettingsKey.toldNewerPeel)+ let answer = NewerPeelNotice.check(newer: library.newerPeel?.version, told: told)+ if answer.told != told {+ defaults.set(answer.told, forKey: SettingsKey.toldNewerPeel)+ }+ if answer.tell, let update = library.newerPeel {+ notifications.notify(newerPeel: update)+ }+ }+ }+/// Runs the update round every hour while update checks are on. Each app's schedule decides whether the round/// checks it.private func askWhenDue() async {@@ -263,7 +279,7 @@ struct PeelApp: App {Navigator.shared.openWindow = openWindowbackground.start([followFolders, followAppsForTheTrash, askWhenDue, followFindings, followActivations, watchFreeSpace,- followHelper,+ followHelper, followNewerPeel,])textEditing.start()sheetInFront.start()diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swiftindex a1d519bf..b801852e 100644--- a/Peel/Views/Settings/SettingsView.swift+++ b/Peel/Views/Settings/SettingsView.swift@@ -145,6 +145,7 @@ enum SettingsKey {static let ignoredUpdateApps = UpdatePreferences.Key.ignoredAppsstatic let skippedUpdateVersions = UpdatePreferences.Key.skippedVersionsstatic let updateMemory = "updateMemory"+ static let toldNewerPeel = "newerPeel.told"/// Nil once the link leads to this copy's tool, and while something that may not be Peel's is where it goes.static func commandLineInstallCommand(diff --git a/README.md b/README.mdindex 24c7491a..b6bcff9a 100644--- a/README.md+++ b/README.md@@ -59,7 +59,7 @@ Homebrew also puts the `peel` command on your path.To update Peel, download the new release and replace the copy in your Applications folder, or run`brew upgrade --cask peel`. Peel asks GitHub once a day whether a new version is out, while update checks are on,and About Peel then says so, with a Download button, or the Homebrew command for a copy Homebrew installed,-and downloads nothing itself.+and downloads nothing itself. If you allow Peel's notifications, one also tells you, once for each version.## What Peel does