Amethyst icon indicating copy to clipboard operation
Amethyst copied to clipboard

Add autominimize setting (AKA window limit)

Open MutatingFunc opened this issue 4 years ago • 14 comments

A proof of concept implementation of #1075, to automatically minimise oldest windows above a certain threshold on a per-space basis, which is configurable in the General Preferences pane. Use a value of 0 to disable the feature, and the max is arbitrarily set to 30. My personal recommendation is using a limit of 3 in Tall layout, and switching to the fullscreen layout (rather than minimising manually) when you want to monotask.

A future direction might be to add a shortcut specifically to toggle the window limit between 1 and the current value, to avoid the need to switch to Fullscreen layout every time. It works for me because I'm only using Tall & Fullscreen, but I could see this becoming an issue.

This is my first time making a change in the Amethyst codebase, and I've had very little experience with AppKit! Feel free to just write the code yourself rather than use this PR; it wasn't a lot of work and I've no idea about the code style guidelines for this project.

If you do use this PR, there are a number of things which will needs doing, apart from a general code tidy-up:

  • The addition of the preference to GeneralPreferencesViewController's Xib layout is a complete hack-job due to my inexperience. It's functional but needs lining up nicely at the very least.
  • The current implementation does not detect and apply the limit when windows are moved across screens. The same is likely also true when moving windows between spaces.
  • It does, however, account for tabs, and correctly applies the window limit on a per-screen basis.
  • There may be other issues! I only use a fraction of Amethyst's capabilities, so this needs some proper testing.

MutatingFunc avatar Dec 21 '20 10:12 MutatingFunc

Not ready for merge, but it'll need looking at by someone more familiar with the project (see above). Therefore I've marked it as ready for review. Feel free to tag this up as you see fit. Thanks!

MutatingFunc avatar Dec 21 '20 10:12 MutatingFunc

I've done a bit of additional work to stop floating windows being minimised, and the solution seems significantly cleaner now that I've adopted the proper method for finding active windows. I'll still need a helping hand UI-wise and resolving any bugs, but I think the core logic is actually alright now.

MutatingFunc avatar Jan 03 '21 12:01 MutatingFunc

Since there's been a lot of changes to make this more intuitive & reliable since the opening comment, here's an update on the current feature-set:

Summary:

  • When a new window is added to a screen, and this puts the total number of windows above the window limit, the oldest non-main window is automatically minimized.
  • Autominimization happens alongside Amethyst's standard reflow pass, and is per-screen.

Configuration:

  • Autominimization does not occur when Amethyst is disabled.
  • Set the window limit in Amethyst's General tab. (The text field is still a few pixels off)
  • Set the window limit to 0 to disable minimization.

Workflows:

  • Main panes are ‘pinned’ - they are never autominimized.
  • In combination with ‘Send new windows to main pane’ disabled, this makes other windows effectively ‘auxiliary’ to the persistent main window's task. Good for focused work.
  • With ‘Send new windows to main pane’ enabled, there is no primary task - old windows flow out as new windows come in. Good for general browsing.
  • Swap to fullscreen to quickly focus on a task, then return to another layout to get back to multitasking.

Pitch to iPad fans:

  • Set window limit to 2, and have just fullscreen & 1 "paned layout" enabled. Cycle between layouts to toggle between fullscreen & split view.
  • Enable "Swap windows using mouse" & "Resize windows using mouse".
  • Set ‘Send new windows to main pane’ to false when you're aiming to get work done with a particular window.
  • Float windows to put them in slide-over mode.

Edit: Strong recommendation:

  • Enable macOS's setting under System Preferences's Dock pane to minimise windows into their dock icon.

@ianyh This branch has evolved a bit beyond a Proof Of Concept. What would need doing to make this a real Amethyst feature?

MutatingFunc avatar Jan 28 '21 20:01 MutatingFunc

Would like to see this becoming part of Amethyst.

I am experimenting with a menu bar app (well, a Hammerspoon script) to show minimized windows per space, and to make visible again. That would be a great companion.

bviefhues avatar Feb 08 '21 20:02 bviefhues

Sounds pretty cool! Love a good custom setup.

Might be worth mentioning for my workflow, I've also got apps set to minimise into the app icon, which generally means they'll pop back up when you click the app! Not sure whether that happens normally, but it certainly helps with the dock clutter this would bring otherwise.

I've also downloaded Swish, which gives you a handy gesture to unminimise windows from the icon, for the odd time that doesn't happen. And to top it off, I've got a downward 3/4F swipe set to minimise the window under the cursor in BetterTouchTool. And I'm working (macOS-style) fullscreen into my flow now too with an upward swipe, having figured out how macOS likes to rearrange spaces. It's like the best of both worlds from macOS and iOS and I'm loving it! 😄

MutatingFunc avatar Feb 08 '21 21:02 MutatingFunc

@bviefhues any chance of sharing the script/git? I'm also looking for a way to show which app's I have open on a given space in my menu bar. I'm using the app 'Context' for now but I'd love to have something akin to showing Icons of the active application per space in the menu bar.

KingOfSpades avatar Feb 09 '21 09:02 KingOfSpades

@KingOfSpades sure, here is a freshly created repo.

Your "active application per space in the menu bar" thing should be doable in Hammerspoon.

bviefhues avatar Feb 09 '21 13:02 bviefhues

May I ask you a compiled version of your amethyst? I’m not a coder and hoping to escape the hassle of installing full xcode, tried it, but unfortunate error with cocoapods and renvb. Thank you.

Bellavene avatar May 13 '22 22:05 Bellavene

If you want to bring this up to date with the main development branch I can work on a review.

ianyh avatar May 22 '22 14:05 ianyh

If you want to bring this up to date with the main development branch I can work on a review.

Thanks! I've just rebased on latest development. The conflicts all seemed to be false-flags - I've gone with the development branch's versions and everything works fine.

Refreshing myself on the contents of the PR, there's a few things I wasn't totally happy with:

  • I'm not sure how you go about laying out the preferences screen to be pixel-perfect. I've never worked with a project that doesn't use constraints. I'd love some advice, or I'd welcome a PR from yourself if you tend to do this yourself.
  • It's not as object-oriented as I'd like - I've got a code smell screenManager.currentLayout is FloatingLayout. If this stands out to you, I'd love some advice your recommended approach, as I was heavily relying on reverse-engineering how the project is put together for this PR.

MutatingFunc avatar May 22 '22 18:05 MutatingFunc

For those interested in trying this branch (@Bellavene 😉), I've uploaded a build on my fork of the repo. Try it out here: https://github.com/MutatingFunc/Amethyst/releases/tag/v1.XX.1

MutatingFunc avatar May 22 '22 18:05 MutatingFunc

Thanks!

Bellavene avatar May 22 '22 18:05 Bellavene

any idea when this might get merged?

rbutera avatar Sep 08 '22 07:09 rbutera

This might be on me, I’ve been putting my time into other things in the last few months. The guard change looks reasonable. I should be able to make time next week to take a look properly.

MutatingFunc avatar Sep 08 '22 07:09 MutatingFunc

@MutatingFunc could you, in a separate PR perhaps, add it to the new documentation?

ianyh avatar Oct 08 '22 02:10 ianyh

@ianyh Thanks! I've raised a PR with some documentation here: https://github.com/ianyh/Amethyst/pull/1319

MutatingFunc avatar Oct 08 '22 09:10 MutatingFunc