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
Show a hidden Peel when its menu bar panel opens
Țugui Dragoș06b164b8a521
diff --git a/GUIDE.md b/GUIDE.mdindex 64092894..a578e3fa 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -417,7 +417,7 @@ With Show in Menu Bar on, Peel's menu bar item lists what each tool found the lathat opens it in Peel. It never adds them up into one figure and never selects anything for you. Turn on Hide from theDock while no window is open as well, and Peel's icon leaves the Dock when you close its last window, then comes backwhen you open Peel again from the menu bar, Finder, or Spotlight. While Peel is hidden its icon stays in the Dock,-where a hidden app is brought back.+and either that icon or Peel's menu bar item brings it back.## The `peel` commanddiff --git a/Peel/Views/MenuBarPanel.swift b/Peel/Views/MenuBarPanel.swiftindex 3654f807..f599a84b 100644--- a/Peel/Views/MenuBarPanel.swift+++ b/Peel/Views/MenuBarPanel.swift@@ -45,6 +45,12 @@ struct MenuBarPanel: View {) { _ inroom = Self.room}+ // macOS draws no window of a hidden app, and after a hidden launch a click on the item leaves Peel hidden.+ .onAppear { Self.showPeelIfHidden(NSApplication.shared) }+ }++ static func showPeelIfHidden(_ app: some HidingApp) {+ if app.isHidden { app.unhideWithoutActivation() }}private var middle: some View {@@ -269,3 +275,10 @@ struct MenuBarPanel: View {dismiss()}}++protocol HidingApp: AnyObject {+ var isHidden: Bool { get }+ func unhideWithoutActivation()+}++extension NSApplication: HidingApp {}diff --git a/PeelTests/MenuBarPanelTests.swift b/PeelTests/MenuBarPanelTests.swiftindex 1d859e65..81ff07ff 100644--- a/PeelTests/MenuBarPanelTests.swift+++ b/PeelTests/MenuBarPanelTests.swift@@ -26,4 +26,30 @@ struct MenuBarPanelTests {@Test func aNewVersionOfPeelHasARowOfItsOwn() throws {#expect(try height(with: PeelUpdater(found: "9.9")) > height(with: PeelUpdater()))}++ @Test func showsAHiddenPeel() {+ let app = StandInApp(isHidden: true)+ MenuBarPanel.showPeelIfHidden(app)+ #expect(!app.isHidden)+ #expect(app.unhides == 1)+ }++ @Test func leavesAPeelThatIsNotHiddenAlone() {+ let app = StandInApp(isHidden: false)+ MenuBarPanel.showPeelIfHidden(app)+ #expect(app.unhides == 0)+ }+}++/// The test host can't be hidden on demand: its activation policy is prohibited while it hosts tests.+private final class StandInApp: HidingApp {+ var isHidden: Bool+ var unhides = 0++ init(isHidden: Bool) { self.isHidden = isHidden }++ func unhideWithoutActivation() {+ unhides += 1+ isHidden = false+ }}