FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
5.77k stars 89 forks source link

space_windows_change's APPS include hidden/minimized windows? #492

Closed shajra closed 8 months ago

shajra commented 8 months ago

The space_window_change trigger provides the APPS variable, which helps render app icons in SketchyBar's spaces.

That seems to work pretty well, though there are some gaps. One gap remaining is with respect to both hiding and minimizing windows. This is kind of unavoidable with Macs because sometimes closing a window closes the application, and other times, it just hides the window. Electron apps like Discord and Slack do this kind of hiding.

What happens now is when a window is hidden/minimized, Sketchybar gets no notification that it's been hidden/minimized. If, in the same space, you create a new window, a trigger is sent that excludes the hidden window from the APPS list. If you move to another space, the inconsistent state will continue in the space with the problem. This doesn't render app icons completely useless, but it can be annoying if you actually look at icons to think about what space to go to.

For now, I've done things like writing skhd keybind captures of Cmd + h so that I can properly remove applications that aren't visible when hiding from SketchyBar and then delegate the actual hiding via an AppleScript.

That does the right thing when hiding. But I end up having the reverse problem when unhiding, which I don't have even a workaround for yet.

It occurred to me that it might be easier to just let the APPs variable include hidden windows. Then there would be nothing to either remove or add.

And for me personally, I actually like that, because minimizing/ hiding isn't about making the application be so out of view I forget about it. It just needs to not be in the way of window management.

What do you think?

FelixKratz commented 8 months ago

This is also something that is bothering me so I will work on it as soon as I have some time. The current implementation of the tracking of app windows is too naive to be able to handle hidden windows properly, but it is easy to make it work with hidden windows as well. Possibly, we could extend the event payload a bit to include a field with the hidden apps on a space.

FelixKratz commented 8 months ago

Ok, so I think this commit should fix the problem: https://github.com/FelixKratz/SketchyBar/commit/a16906a59dd22e1b2c886f47a33ae728bd39a69b I am keeping track of the hidden windows separately and it would be possible to add this info to another field in the event.