Repository navigation
Fix menu bar items shifting when a value changes width (e.g. 9% → 10%) #146
braidskywalker
started this conversation in
Ideas
Replies: 2 comments
|
Thank you very much!
What a nice app you made. I was using Stats, but its network monitor
somehow eats some of my bandwidth / latency - yours don't. So I'm keeping
it forever. Thank you.
…On Sat, Nov 28, 2026 at 4:21 PM offyotto ***@***.***> wrote:
Hi; I've opened a PR for this. #147
<#147>
—
Reply to this email directly, view it on GitHub
<#146?email_source=notifications&email_token=A7ZDCJ3FCUE6LJTLD4S4DRD53MQT5A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJZHAZTGNRTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-19983363>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A7ZDCJZNW5SMIABKV37K4BD53MQT5AVCNFSNUABJKJSXA33TNF2G64TZHMYTCNZVGM2DSNRTGA5UI2LTMN2XG43JN5XDWMJRGQZDANZVGGQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/A7ZDCJYRYPOW34MM2DNBSHT53MQT5A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJZHAZTGNRTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVJTG633UMVZF62LPOM>
and Android
<https://github.com/notifications/mobile/android/A7ZDCJ6RRTK3YICKGRCCDZ353MQT5A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJZHAZTGNRTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE>.
Download it today!
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Each menu bar item uses NSStatusItem.variableLength, so macOS resizes the item whenever its text changes width. When a value gains a digit (for example CPU going from 9% to 10%), the item grows and pushes neighboring menu bar icons to the side. This happens repeatedly during normal use and is distracting.
Change
Keep track of the widest label each item has displayed (reservedLabelWidth). The value only grows, so the item settles at its maximum width instead of resizing on every change.
Set statusItem.length to the icon width plus the reserved label width.
Set button.alignment = .left so the icon stays in place when the text is narrower than the reserved space.
The change is limited to Core-Monitor/MenubarController.swift. No changes to how values are read or formatted.
Trade-offs
The item takes the width of its widest value seen so far. For the network item, which can range from ↓999KB to ↓12MB, the item will be as wide as its peak until the app restarts.
Each item widens once, the first time a larger value appears. Fixing the initial width per metric (for example 100% for CPU) would remove that step, and I can add it if you prefer.
// New property in the class
private var reservedLabelWidth: CGFloat = 0
func updateStatusButton() {
let state = statusButtonState()
if statusItem.isVisible != state.isVisible {
statusItem.isVisible = state.isVisible
}
guard state.isVisible, let button = statusItem.button else {
lastStatusState = state
return
}
guard lastStatusState != state else { return }
}
All reactions