Add menu-bar-item config option to hide the menu bar item - #2241
Add menu-bar-item config option to hide the menu bar item#2241christophervalles wants to merge 1 commit into
Conversation
AeroSpace's MenuBarExtra is the app's only SwiftUI scene. Removing it (e.g. via MenuBarExtra(isInserted:)) leaves the App with no active scene, which the system terminates — even for an LSUIElement agent app. So the menu bar item can't be removed outright. Instead, 'menu-bar-item = false' keeps the scene present and collapses the label to a single compact icon (square.split.2x2) in place of the workspace readout. This is for users who run their own workspace indicator (SketchyBar, etc.) and don't want the duplicate. Defaults to true (unchanged behavior). TrayMenuModel.menuBarItemIsShown mirrors config.menuBarItem and is updated in updateTrayText (guarded to avoid a redundant @published republish on every refresh).
80dce95 to
e37abe6
Compare
|
Revised the implementation. The original approach used So a full removal isn't achievable while |
Summary
AeroSpace always shows its own item in the macOS menu bar (the per-monitor workspace readout, e.g.
1 │ 2 │ *3). Users who already run a separate workspace indicator — SketchyBar, a waybar-style bar, etc. — end up with a duplicate they can't turn off from config.This adds an opt-in config option to hide it:
How it works
menu-bar-itembool onConfig(defaulttrue), parsed with the existingparseBool.TrayMenuModelgets a@Published var menuBarItemIsShown, whichupdateTrayText()keeps in sync withconfig.menuBarItem.MenuBarExtrascene is created with theisInserted:initializer bound tomenuBarItemIsShown. Setting itfalseremoves the item from the menu bar entirely.Because
updateTrayText()runs on every session refresh, the item appears/disappears live onreload-config— no relaunch needed.Default is
true, so behavior is unchanged unless the option is opted into.Test plan
swift build— clean.swift test— all pass, incl. a newtestParseMenuBarItem(defaulttrue, parsestrue/false, rejects a non-bool)../lint.sh— SwiftFormat clean, no unused code.menu-bar-item = false, AeroSpace's menu bar item is gone; toggling back totrue+reload-configbrings it back without relaunch.Files
Sources/AppBundle/config/Config.swift— the config fieldSources/AppBundle/config/parseConfig.swift— registry entrySources/AppBundle/ui/TrayMenuModel.swift— published flag + sync inupdateTrayTextSources/AppBundle/ui/MenuBar.swift—MenuBarExtra(isInserted:)Sources/AppBundleTests/config/ConfigTest.swift—testParseMenuBarItemdocs/config-examples/default-config.toml— documented default