-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
Persist window state to directory #761
Conversation
Hey thanks for sharing this first draft! It's nice to see you got useful results so fast! Regarding the preferences, I'm a bit worried as I've learned on this project how they can grow out of control. I'm thinking that an opt-in checkbox is necessary because of the potential perf impact, but also the certain "intrusiveness" (as in, the user may expect the app to not write anything on disk, given its functionality). Regarding your todo list:
I think that you should use async IO to write to disk. Then I expect the performance impact should be almost null. To benchmark it, you could use Instruments and do a before/after the change. That's how I get a general performance understanding of changes that I suspect would impact performance.
Because this app is 100% side-effects from OS interactions, I gave up on automated testing from the get go. I kind of regret it sometimes, as probably some unit tests here and there would have helped, but at the same time even in retrospect I feel I made the right call back then. So there are no automated tests today; it's all manual QA. I have a section if you're curious to see the kind of fun macOS had in store when I built this app.
You may want to discuss this with @v-braun and see what kind of usage he would have of it, to decide what to expose. A good start would be to expose the list of windows observed, with all their attributes. Other useful stuff may include the info on Spaces, Screens, running Applications. By the way, I realized that your approach of exporting the state of the app as JSON is useful to get info on the state, but will not allow the user to interact with the windows or other elements. For the window for instance, even if you exported their ID, and passed it to some AppleScript, it couldn't work in all cases. I'm using private APIs and private SPIs to focus windows, as there is no public API to do it correctly for some edge-cases (like windows on other Spaces, or minimized in the Dock on other Spaces, I forgot)
If you serialization code is fast enough, you probably want to rewrite the whole file on any change in the state, instead of updating specific lines by doing delta changes. You may put the update code after this switch. If you're exposing Applications state, you may want to add the update code here as well.
Yes, please! These updates are really tricky as they usually break CI, thus involve extra work/care to fix it. I have setup a full CI > CD pipeline that releases apps to the public, so breaking it is a critical thing. Unless an update is trully useful/necessary, I would avoid updating cocoapods 😅 |
Preferences: This is what I have right now, I thought I need the button, but actually I might not for the path control + I need to make it show the icons, it's a bit bland right now. I think it also fails silently on permissions issues right now to I need to put that in somewhere too: This worked well enough for me with osascript for alfred (including changing to windows in different spaces) (yes ALOT of stackoverflow there). I never minimize / hide so I haven't tested those specifically
Regarding cocoapods, I definitely had to upgrade my targeting atleast, I might not have needed to do the |
Any particular reason you don't want to use #768 with a HTTP? Otherwise I can see if I can revert the changes on the reflog for this PR |
Mainly laziness 😅. You have an Alfred WF for this one & all 😛. Do you have a WF that works with the other PR? 🙂 (also got scared by other pr's size initially, but it seems most of the code is copying source of a library? btw I'm Swift ignorant, so I'm curious on why you'd want to do that vs dependency?). |
@Stvad I made #886 (sorry couldn't do it to this pr) for posterity. I've only made my workflow work for the HTTP one now so see that PR for details. Dependencies are checked into git, otherwise they work in a similar way to other languages. I'm not sure if it's strictly necessary, but this is called "vendoring" and it's pretty common especially for lower level languages. Obviously most useful if you want to make changes, whether for performance or compatibility reasons, or for more of a "it just works" when sharing a repo |
@ayroblu thanks a lot! |
I'm pretty sure your osacript will not work in every case, unfortunately. AltTab uses private API and private SPI to enable focusing every window in every situation. Maybe good enough for your particular usage though, which is already great! |
In a first attempt to tackle #371, I thought that writing to the filesystem would be useful.
Menu layout:

(I'm using a ram disk as volatile fyi)
I then hooked this up to alfred and it worked as expected!:
TODO:
Documents/alt-tab-windows.json
, probably with button + NSPathControl