-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] Ability to have hs.menubar items retain their same position upon startup/hs.reload (or at least next to the "main" Hammerspoon menubar item) rather than always reverting back to the left-most item #2878
Comments
Same problem, it resets to the leftmost side every time it starts, very annoying |
bump on this! |
This might be helpful?
EDIT: looks like Hammerspoon already had ability to set the "priority" but this no longer works on Catalina and above. |
Maybe the issue is as simple as just not supplying the menubar items an autosavename? https://developer.apple.com/documentation/appkit/nsstatusitem/1644022-autosavename |
We don't use We can't change menu position programmatically anymore -- that was removed in Catalina. I do wonder if setting an |
My guess is that it'll most likely fix things, as without an |
- Added an optional `autosaveName` parameter to `hs.menubar.new()`, which allows you to set a unique identifier for the menubar, allowing it to save and restore it's menubar position across reloads. - Added a method to get and set the `autosaveName` -`hs.menubar:autosaveName()`. - Removed `hs.menubar.newWithPriority()` as it no longer works on macOS Catalina (and the minimum system requirements for Hammerspoon are now Catalina & above). - Closes Hammerspoon#2878
I've just added a pull request (#3195) which seems to do the trick. |
Hey @latenitefilms thank you for doing this, really cool stuff. I checked out your branch, compiled Hammerspoon.app in Xcode, moved it to Applications folder, allowed permissions, then updated my .hammerspoon code to include this:
After I move the icon, I click it to trigger the autosaveName method. But after I reload hammerspoon, it shoots back to the left again. Any ideas? |
Try setting the autosaveName when creating the menubar instead, as opposed to using the autosaveName method. I might need to tweak the method if it's not working as intended. |
I've just pushed a fix for the Here's some example code for testing: a = hs.menubar.new(true, "A"):setTitle("A")
b = hs.menubar.new(true, "B"):setTitle("B")
c = hs.menubar.new(true):autosaveName("C"):setTitle("C")
z = hs.menubar.new(true):setTitle("Z") -- this won't save position To test, run the above code in the Console, change the menubar icon positions, restart Hammerspoon, then run the code again. |
When I try to build the hammerspoon app in Xcode I get this error:
|
This worked on the last build that I made, thank you for the fix! |
Opps - I've fixed the documentation bug. Thanks! |
- Added an optional `autosaveName` parameter to `hs.menubar.new()`, which allows you to set a unique identifier for the menubar, allowing it to save and restore it's menubar position across reloads. - Added a method to get and set the `autosaveName` -`hs.menubar:autosaveName()`. - Removed `hs.menubar.newWithPriority()` as it no longer works on macOS Catalina (and the minimum system requirements for Hammerspoon are now Catalina & above). - Closes #2878
This doesn't work in the latest release. Was it included in release? |
It was not included Commit was pushed about a month after the latest release. |
Not sure this is even possible given the way Hammerspoon utilizes the APIs for hs.menubars/how the system behaves but just thought I'd raise the question. This is something that would benefit me and my personal workflow quite significantly as I utilize multiple hs.menubar items heavily and have a lot of non-HS items which means they aren't all always visible and so every time I reload, I have to move them all back to an always-visible section of menubar one by one.
Steps to reproduce:
The text was updated successfully, but these errors were encountered: