From 4cbf8a1a4f2e046f34e744b2d9d86d6af7dd811f Mon Sep 17 00:00:00 2001 From: Roy Padina <4943097+roypadina@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:02:13 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Settings:=20apps=20on=20both=20sides=20of?= =?UTF-8?q?=20the=20icon=20=E2=80=94=20show=20or=20hide=20(local,=20unrele?= =?UTF-8?q?ased)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014uzkEWCUtd8FePAkNCZdpS --- AX.swift | 6 ++++++ Hiding.swift | 1 + Settings.swift | 10 +++++++++- tests/main.swift | 7 +++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/AX.swift b/AX.swift index 9628c90..d4efdc4 100644 --- a/AX.swift +++ b/AX.swift @@ -88,6 +88,12 @@ func menuBarCanShow(running: URL?, resolved: URL?) -> Bool { return running.standardizedFileURL.path.hasPrefix("/Applications/") } +/// Bundles kept on the bar while hiding. The allow-list is per bundle, so an app with items on both sides of our icon is +/// shown whole, or hidden whole with Settings › "Apps on both sides of the icon" = Hide (`splitHides`). +func rightOfUs(_ right: Set, _ left: Set, splitHides: Bool) -> Set { + splitHides ? right.subtracting(left) : right +} + /// One walk plus our own frame, sampled every 20 ms from `settle` s before the walk to its end. Our item moving meanwhile = /// the bar re-laid out (an allow-list just dropped items right of us, or one changed width), so the walk mixes old and new /// x for apps that moved with us and left/right of us is wrong: nil = read again. Sampled, not just before/after: an item diff --git a/Hiding.swift b/Hiding.swift index 9eb12ec..07139c3 100644 --- a/Hiding.swift +++ b/Hiding.swift @@ -131,6 +131,7 @@ extension Lister { else if fromRight(e.x + e.width / 2, e.y) < fromRight(me.midX, me.minY) { right.insert(b) } else { left.insert(b) } } + right = rightOfUs(right, left, splitHides: UserDefaults.standard.string(forKey: "splitApps") == "hide") // Parked for more than a poll although our list allows it = macOS itself keeps it off the bar: System Settings › // Menu Bar › "Allow in the Menu Bar" is off for that app (MenuBarAgent persists it per app and parks the item at // creation, whatever any allow-list says). Nothing we activate or release places it — a release only flashes the diff --git a/Settings.swift b/Settings.swift index 72f7347..02dc55c 100644 --- a/Settings.swift +++ b/Settings.swift @@ -31,6 +31,7 @@ struct SettingsView: View { @AppStorage("hoverReveal") var hoverReveal = false @AppStorage("clickEmptyBar") var clickEmptyBar = false @AppStorage("newApps") var newApps = "show" + @AppStorage("splitApps") var splitApps = "show" @State var axOK = AXIsProcessTrusted() @State var screenOK = CGPreflightScreenCaptureAccess() @State var clickModes = UserDefaults.standard.dictionary(forKey: "clickModes") as? [String: String] ?? [:] @@ -73,7 +74,14 @@ struct SettingsView: View { } Toggle("Show items when hovering empty menu bar space", isOn: $hoverReveal) Toggle("Click empty menu bar space to show / hide", isOn: $clickEmptyBar) - } header: { Text("General") } + Picker("Apps on both sides of the icon", selection: $splitApps) { + Text("Show").tag("show") + Text("Hide").tag("hide") + }.onChange(of: splitApps) { if lister.hidden { lister.hideNow() } } + } header: { Text("General") } footer: { + Text("macOS hides whole apps, so an app with icons on both sides of the SmartHiddenBar icon shows or hides all of them together.") + .foregroundStyle(.secondary) + } Section { ForEach(NSScreen.screens, id: \.localizedName) { screen in Picker(screen.localizedName, selection: Binding( diff --git a/tests/main.swift b/tests/main.swift index 0fa2a47..bef11ba 100644 --- a/tests/main.swift +++ b/tests/main.swift @@ -49,4 +49,11 @@ precondition(!menuBarCanShow(running: nested, resolved: support), "LaunchService precondition(!menuBarCanShow(running: nested, resolved: nil), "id unknown to LaunchServices") precondition(!menuBarCanShow(running: u("/Applications-old/X.app"), resolved: u("/Applications-old/X.app")), "prefix, not a folder") +// Settings › "Apps on both sides of the icon": the allow-list is per bundle, so an app with items left and right of us +// (iStat Menus) is shown whole (default) or hidden whole. +let seenRight: Set = ["com.bjango.istatmenus.status", "HamedElfayome.Claude-Usage"] +let seenLeft: Set = ["com.bjango.istatmenus.status", "ru.keepcoder.Telegram"] +precondition(rightOfUs(seenRight, seenLeft, splitHides: false) == seenRight, "split app shown: default, as before") +precondition(rightOfUs(seenRight, seenLeft, splitHides: true) == ["HamedElfayome.Claude-Usage"], "split app hidden") + print("selfcheck: ok") From 3d88d15e3cd43a303b271cd15fec433422a1654b Mon Sep 17 00:00:00 2001 From: Roy Padina <4943097+roypadina@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:04:31 +0200 Subject: [PATCH 2/2] Docs for apps on both sides of the icon; 1.5.0 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 8 ++++++++ CLAUDE.md | 2 +- Info.plist | 4 ++-- README.md | 6 +++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8544adb..e90bfb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.5.0] - 2026-10-30 + +### Added +- Settings › General › **Apps on both sides of the icon**: Show or Hide. macOS hides whole apps, so an app with items left and right of the SmartHiddenBar icon (iStat Menus, for example) used to stay fully visible; choose Hide to hide all of its items instead. Show stays the default. + +### Changed +- README and wiki explain why hiding is per app: macOS offers no per-item way to hide another app's icons. + ## [1.4.1] - 2026-10-30 ### Fixed diff --git a/CLAUDE.md b/CLAUDE.md index 67e1d73..8786ec9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,6 +1,6 @@ # SmartHiddenBar -macOS 27 menu bar app: hides every status item left of its own icon via MenuBarAgent's private allow-list (left click = per-display click mode `clickModes[screen.localizedName]`: cycle show → icon bar → hide / toggle / icon bar only; ⌥-click / hotkey open the icon bar with everything currently off the bar, under our icon; no double click — the icon is drawn by MenuBarAgent, so a click on it first hits our global monitor: `barUp` treats a bar closed < 0.5 s ago as open). `alwaysHidden` bundles stay restricted even while shown (restriction then active in both states); `newApps = hide` adds never-seen bundles (`knownApps`) to it. Optional hover / click on bare menu bar (`hoverReveal`, `clickEmptyBar`; AX hit test role AXMenuBar at x and x ± 20 pt, since icon gaps up to 16 pt also report AXMenuBar). Assessment mode blocks Notification Center even with `com.apple.notificationcenterui` allowed (tested), so a clock click (`com.apple.menuextra.clock`) lifts the restriction until NC has no on-screen window. Hiding applies from the cached inventory first (`hideNow`), the AX walk runs in parallel (~130 processes × ~20 ms), lists every app's item via the Accessibility API (`AXExtrasMenuBar`) and mirrors their menus (right-click → Menu Bar Apps ▸; menu = Show Items/Hide Items · Disable/Enable · Menu Bar Apps ▸ · Settings… · About · Support · Quit SmartHiddenBar; `disabled` = no restriction at all, always-hidden included, any click opens the menu, persisted), optional icon bar (⌥-click / its shortcut). Five global shortcuts recorded in Settings (`Shortcuts.swift` `shortcutActions`, Carbon hot keys): show/hide items, icon bar (default ⌃⌥B; the old `hotkey` preset migrates once), list apps, settings, quit — all others default off. Stored as `toggleShortcut` / `barShortcut` / `appsShortcut` / `settingsShortcut` / `quitShortcut` = `"keyCode:carbonMods"`, `""` = off. ⌃⌥M clashes with Wispr Flow. Settings/About/Welcome open through `AccessoryWindows` (Settings.swift: regular app + Dock tile while a window is open, `.accessory` after) with a minimal main menu; opening the app again shows Settings (`applicationShouldHandleReopen`); the Welcome window (Welcome.swift, `didShowWelcome`, re-entry Settings → About → Welcome Guide…) replaces the first-run alert; the status icon turns into a warning triangle without Accessibility or after a failed hide. Swift sources in the repo root (`*.swift`), built by `./build.sh` (icon set chosen by `SET=` at its top, assets in `Assets/icons/`, regenerated by `Assets/icons/gen.py`). +macOS 27 menu bar app: hides every status item left of its own icon via MenuBarAgent's private allow-list (left click = per-display click mode `clickModes[screen.localizedName]`: cycle show → icon bar → hide / toggle / icon bar only; ⌥-click / hotkey open the icon bar with everything currently off the bar, under our icon; no double click — the icon is drawn by MenuBarAgent, so a click on it first hits our global monitor: `barUp` treats a bar closed < 0.5 s ago as open). `alwaysHidden` bundles stay restricted even while shown (restriction then active in both states); `newApps = hide` adds never-seen bundles (`knownApps`) to it. `splitApps` (Settings › General › Apps on both sides of the icon, `show` default / `hide`): an app with items on both sides is allowed whole or denied whole (`rightOfUs`, AX.swift) — no per-item hiding exists on macOS 27: the restriction XPC (`com.apple.MenuBarAgent.visibility-restriction`) sends bundle ids only, listing other apps' items needs `com.apple.private.menubar.utilities`, and a 10 000 pt separator item is dropped by MenuBarAgent instead of pushing items off (tested 2026-10-30). Optional hover / click on bare menu bar (`hoverReveal`, `clickEmptyBar`; AX hit test role AXMenuBar at x and x ± 20 pt, since icon gaps up to 16 pt also report AXMenuBar). Assessment mode blocks Notification Center even with `com.apple.notificationcenterui` allowed (tested), so a clock click (`com.apple.menuextra.clock`) lifts the restriction until NC has no on-screen window. Hiding applies from the cached inventory first (`hideNow`), the AX walk runs in parallel (~130 processes × ~20 ms), lists every app's item via the Accessibility API (`AXExtrasMenuBar`) and mirrors their menus (right-click → Menu Bar Apps ▸; menu = Show Items/Hide Items · Disable/Enable · Menu Bar Apps ▸ · Settings… · About · Support · Quit SmartHiddenBar; `disabled` = no restriction at all, always-hidden included, any click opens the menu, persisted), optional icon bar (⌥-click / its shortcut). Five global shortcuts recorded in Settings (`Shortcuts.swift` `shortcutActions`, Carbon hot keys): show/hide items, icon bar (default ⌃⌥B; the old `hotkey` preset migrates once), list apps, settings, quit — all others default off. Stored as `toggleShortcut` / `barShortcut` / `appsShortcut` / `settingsShortcut` / `quitShortcut` = `"keyCode:carbonMods"`, `""` = off. ⌃⌥M clashes with Wispr Flow. Settings/About/Welcome open through `AccessoryWindows` (Settings.swift: regular app + Dock tile while a window is open, `.accessory` after) with a minimal main menu; opening the app again shows Settings (`applicationShouldHandleReopen`); the Welcome window (Welcome.swift, `didShowWelcome`, re-entry Settings → About → Welcome Guide…) replaces the first-run alert; the status icon turns into a warning triangle without Accessibility or after a failed hide. Swift sources in the repo root (`*.swift`), built by `./build.sh` (icon set chosen by `SET=` at its top, assets in `Assets/icons/`, regenerated by `Assets/icons/gen.py`). ## Rules - **Always run the `/Applications/SmartHiddenBar.app` copy, never `build/`.** On macOS 27, MenuBarAgent resolves allow-listed bundle ids through LaunchServices, which picks the `/Applications` copy; a copy running from `build/` never matches, so the allow-list hides its own icon wherever it sits. `build.sh` installs to `/Applications` unless that copy is running — quit it first, then rebuild. diff --git a/Info.plist b/Info.plist index e3e7536..1c993bb 100644 --- a/Info.plist +++ b/Info.plist @@ -13,9 +13,9 @@ CFBundleIconFile AppIcon CFBundleShortVersionString - 1.4.1 + 1.5.0 CFBundleVersion - 14 + 15 LSMinimumSystemVersion 27.0 NSHumanReadableCopyright diff --git a/README.md b/README.md index 7817595..5a15b09 100644 --- a/README.md +++ b/README.md @@ -99,21 +99,21 @@ On first run, follow the Welcome window, then ⌘-drag the SmartHiddenBar icon t | Hover an icon in the icon bar | Its app name | | Right-click (or ⌃-click) | Show Items / Hide Items · Disable/Enable SmartHiddenBar · Menu Bar Apps ▸ (every third-party menu bar app; pick one to use its menu) · Settings… · About · Support · Quit SmartHiddenBar | -Settings (sections: General, Click, Shortcuts, Icon Bar, Permissions, Always Hidden, About): Open at Login, auto-rehide (after a delay or when the pointer leaves the bar), hover / empty-space click, click mode per display, always-hidden apps and what happens to new ones, five recordable shortcuts (show/hide items, icon bar, list apps, settings, quit; all off by default except the icon bar: click the shortcut, press a combo with ⌃, ⌥ or ⌘; Esc cancels, Delete or Off clears), app icons vs. real menu bar icons, icon size and names in the icon bar, and permission status. +Settings (sections: General, Click, Shortcuts, Icon Bar, Permissions, Always Hidden, About): Open at Login, auto-rehide (after a delay or when the pointer leaves the bar), hover / empty-space click, what happens to apps with items on both sides of the icon, click mode per display, always-hidden apps and what happens to new ones, five recordable shortcuts (show/hide items, icon bar, list apps, settings, quit; all off by default except the icon bar: click the shortcut, press a combo with ⌃, ⌥ or ⌘; Esc cancels, Delete or Off clears), app icons vs. real menu bar icons, icon size and names in the icon bar, and permission status. ## How it works macOS 27's `MenuBarAgent` has a private "assessment mode" allow-list (`MenuBarClientCore`): while a process holds it, the bar shows only the allowed apps plus system items. SmartHiddenBar allows itself, the system items, and every app whose item sits to the right of its icon; apps left of the icon are denied. Hiding is -therefore **per app, not per item**. Nothing is moved or modified: quitting SmartHiddenBar +therefore **per app, not per item** (the API takes app ids only; there is no per-item call). Nothing is moved or modified: quitting SmartHiddenBar (or "Show Items") releases the allow-list and the full bar comes back. Item lists and menus are read, and menu items pressed, through the Accessibility API (`AXExtrasMenuBar`). Mirroring copies the real menu, closes it, and replays your pick on the real one. ## Limitations - **macOS 27 only.** It relies on a **private API** that Apple can change or remove in any update; if it is missing, SmartHiddenBar tells you and leaves everything visible. -- Hiding is **per app**: an app with several items hides or shows them together. +- Hiding is **per app**: macOS only hides whole apps, so an app with several items (iStat Menus, for example) hides or shows them together. If its items sit on both sides of the SmartHiddenBar icon, Settings → General → **Apps on both sides of the icon** decides: Show (default) keeps all of them, Hide hides all of them. To split such an app, ⌘-drag all its items to one side of the icon. - **Apple's own items** (Control Center, Wi-Fi, clock, ...) can't be hidden. - Only items **left of SmartHiddenBar's icon** are hidden (plus your always-hidden apps). - macOS blocks Notification Center while hiding is active, so a click on the clock shows the hidden items until it closes.