fix: add autosaveName to all Spoons with menubar items#362
Open
johntrandall wants to merge 2 commits intoHammerspoon:masterfrom
Open
fix: add autosaveName to all Spoons with menubar items#362johntrandall wants to merge 2 commits intoHammerspoon:masterfrom
johntrandall wants to merge 2 commits intoHammerspoon:masterfrom
Conversation
Without autosaveName, macOS creates NSStatusItems without a stable identifier. When items are destroyed and recreated (e.g., on Hammerspoon config reload, or when a Spoon dynamically shows/hides its menubar item), macOS treats them as brand-new items and places them at the far-left of the menubar. This breaks compatibility with popular menubar managers (Ice, Bartender, Hidden Bar, Vanilla) that track item positions — they misclassify recreated items as unknown and hide them. Setting autosaveName gives macOS a persistent key to remember each item's user-chosen position across destroy/recreate cycles. Affected Spoons: Caffeine, Cherry, ClipboardTool, ColorPicker, CountDown, EjectMenu, MicMute, PushToTalk, Shade, SpeedMenu, TextClipboardHistory, TimeMachineProgress, TurboBoost, ZeroOffset Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 10, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
autosaveNameparameter to allhs.menubar.new()calls across 14 Spoons that create persistent menubar items"Caffeine","TimeMachineProgress")Problem
Without
autosaveName, macOS createsNSStatusItems without a stable identifier. When items are destroyed and recreated (on Hammerspoon config reload, or when a Spoon dynamically shows/hides its menubar item), macOS treats them as brand-new and places them at the far-left of the menubar.This breaks compatibility with third-party menubar managers that track item positions:
Setting
autosaveNamegives macOS a persistent key to remember each item's user-chosen position across destroy/recreate cycles. This is the standard practice for well-behaved macOS apps —NSStatusItem.autosaveNamehas been available since macOS 10.12.Affected Spoons
Caffeine, Cherry, ClipboardTool, ColorPicker, CountDown, EjectMenu, MicMute, PushToTalk, Shade, SpeedMenu, TextClipboardHistory, TimeMachineProgress, TurboBoost, ZeroOffset
Change pattern
Every change follows the same minimal pattern — adding the Spoon name as the second argument:
For Spoons that already pass
inMenuBaras the first arg (e.g.,CountDown,Cherry,SpeedMenu), only the second argument is appended:Note:
ClipboardToolhas a secondhs.menubar.new(false)call (line 283) used for an ephemeral popup context menu — this was intentionally left unchanged as it is not a persistent menubar item.Test plan
hs.menubar.new(inMenuBar, autosaveName)signature is supported (parameter added in Hammerspoon core)truematches the defaultinMenuBarvalue🤖 Generated with Claude Code