-
Notifications
You must be signed in to change notification settings - Fork 8
Add option to remove desktop after focus change #3
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,12 +134,16 @@ func (r RemoveHandler) ShouldHandle() bool { | |
|
|
||
| func (r RemoveHandler) Handle(m *monitors.Monitors) bool { | ||
| for _, monitor := range *m { | ||
| if len(monitor.EmptyDesktops()) == 1 { | ||
| return true | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see that now. Side note: I will fix formatting in the next commit |
||
| for _, desktop := range monitor.EmptyDesktops() { | ||
| if *desktop == monitor.Desktops[len(monitor.Desktops)-1] { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for taking this check out? This prevents removing the last desktop if it's empty
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember the reason, but can test when I spin up a vm with bspwm later this week. I vaguely remember that this line did not respect the minimum desktop configuration, and would end up removing more desktops than the user has configured (if they have a minimum of 3 desktops, this may remove that third desktop) |
||
| if r.config.Min >= len(monitor.Desktops) { | ||
| continue | ||
| } | ||
|
|
||
| if r.config.Min >= len(monitor.Desktops) { | ||
| // TODO: Should we handle desktop destruction if the monitor focus is switched? | ||
| if !r.config.RemoveFocused && monitor.FocusedDesktopId == desktop.Id { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cmschuetz One side effect of this is that an empty desktop could end up in the middle of the desktops. I suggest adding in a This would share a similar
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we accomplish the desired outcome with this line as-is without the need for adding a new handler. Essentially, we want this function to take no action if With the above, if desktop
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like it would do it. |
||
| continue | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cmschuetz Should
btopsdefault to not removing focused desktops by default (false) or should it keep the previous behavior of removing focused desktops (true)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep it in line with previous behavior, so I think
truehere works.With that said,
remove-focusedis sort of tied toremove-emptyas it shouldn't have any effect ifremove-emptyis false and so this naming might be a bit confusing taken out of contextWas thinking about this a bit and figured we could merge this config with
remove-emptybut instead provide a distinct option for this case.E.g. possible options:
remove-empty: [true, unfocused, false]We'd have to change this config from a bool to a string but I think this strikes a nice balance without adding more top-level configs and would not be a breaking change.
Long term I was thinking we could possibly supply a white-list of applications where this rule applies. E.g. remove all empty, focused desktops except when the last closed program was steam. This is something I would personally want as it's annoying to open steam while it brings up and tears down several windows. However, this would require a substantial code change as we'd need a log of previous bspwm states and I think we can solve this problem in other ways, will create issues for some more ideas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, and I agree (looking back now) that remove-focused is confusing.
Perhaps desktop pinning would be a solution to your second note?
I.E. allow a way to "pin" a desktop from being removed even
remove-empty = true.For a whitelist, maybe a configurable timeout before removing could be written? For example, if Steam opens on a desktop, that desktop will have a timeout of say 60s before it is removed if it's empty. This can rely on a check added to the main loop.