Explain which menu bar items can be hidden

Hiding other apps' icons worked, but Apple pins Spotlight, Clock, Battery
and Control Center to the right of the menu bar, so a third-party item can
never be placed after them to push them away. Document the real limit so
the behaviour is not mistaken for a bug.

💘 Generated with Crush

Assisted-by: Crush:deepseek-v4.1-flash
This commit is contained in:
2026-09-27 00:35:05 +08:00
parent 8767b73234
commit 92a57308b7
6 changed files with 46 additions and 7 deletions
+8
View File
@@ -53,6 +53,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
return
}
if CommandLine.arguments.contains("--diag-hide") {
MenuBarHider.shared.enabled = true
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
dumpMenuBarItems()
}
return
}
// The tray is empty without Accessibility permission, so surface the
// system prompt once at launch instead of waiting for the user to open
// the panel and find the button.
+8
View File
@@ -165,7 +165,15 @@ final class MenuBarHider: ObservableObject {
/// Create the spacer early (at launch) so it lands as far right as possible.
func prepare() {
guard spacer == nil else { return }
let name = "SimpleTopBarHider"
let key = "NSStatusItem Preferred Position \(name)"
// Seed just left of the hamburger so growing the spacer pushes the
// third-party icons on its left off-screen while ours stays put.
if UserDefaults.standard.object(forKey: key) == nil {
UserDefaults.standard.set(150.0, forKey: key)
}
let item = NSStatusBar.system.statusItem(withLength: 0)
item.autosaveName = name
item.button?.isHidden = true
spacer = item
}
+1 -1
View File
@@ -115,7 +115,7 @@ struct TopBarView: View {
.controlSize(.mini)
.padding(.horizontal, 12)
.padding(.top, 6)
.help("Best-effort: pushes the real items off the menu bar so they only live here. Reliable when SimpleTopBar starts at login.")
.help("Best-effort: pushes other apps' icons off the menu bar so they only live here. Apple's Spotlight, Clock, Battery and Control Center stay pinned on the right and cannot be moved by any third-party app.")
}
}
}