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

Bar not sticky on space change #493

Closed aashish2057 closed 8 months ago

aashish2057 commented 8 months ago

Really want to use this but the bar keeps blinking and settings sticky doesn't fix it. I attached a recording of the blinking.

The result of running sketchybar --query bar

{
        "position": "top",
        "topmost": "off",
        "sticky": "on",
        "hidden": "off",
        "shadow": "off",
        "font_smoothing": "off",
        "blur_radius": 30,
        "margin": 0,
        "drawing": "on",
        "color": "0xff101314",
        "border_color": "0xffff0000",
        "border_width": 0,
        "height": 32,
        "corner_radius": 0,
        "padding_left": 10,
        "padding_right": 10,
        "y_offset": 0,
        "clip": 0.000000,
        "image": {
                "value": "(null)",
                "drawing": "off",
                "scale": 1.000000
        },
        "items": [
                 "space.1",
                 "space.2",
                 "space.3",
                 "space.4",
                 "space.5",
                 "space.6",
                 "space.7",
                 "space.8",
                 "space.9",
                 "space.10",
                 "space_separator",
                 "front_app",
                 "clock",
                 "volume",
                 "battery"
        ]
}

https://github.com/FelixKratz/SketchyBar/assets/42164334/4114aa39-cbd7-4a51-960d-c937c6b6d981

aashish2057 commented 8 months ago

I noticed this issue #220 , that suggested on sonoma we can use sticky=on to prevent the flickering, I am on Sonoma 14.2.1 still having this issue. I saw @ralphptorres not have this issue when not using yabai with sip on sonoma so curious if anyone knows what I could be doing wrong. I am confused because the sketchybar docs suggest to only use this with animations disabled, something that you can only do with yabai and sip disabled, but hoping there is a way to do it without that as I run yabai with sip enabled.

FelixKratz commented 8 months ago

On Sonoma, the sticky property should not be needed anymore, it is interesting that your bar flickers on space change, can you try with this minimal sketchybarrc and report if the problem persists?

sketchybarrc:

sketchybar --bar height=40 color=0xffffffff sticky=on
aashish2057 commented 8 months ago

yeah same problem still flickering

{
        "position": "top",
        "topmost": "off",
        "sticky": "on",
        "hidden": "off",
        "shadow": "off",
        "font_smoothing": "off",
        "blur_radius": 0,
        "margin": 0,
        "drawing": "on",
        "color": "0xffffffff",
        "border_color": "0xffff0000",
        "border_width": 0,
        "height": 40,
        "corner_radius": 0,
        "padding_left": 20,
        "padding_right": 20,
        "y_offset": 0,
        "clip": 0.000000,
        "image": {
                "value": "(null)",
                "drawing": "off",
                "scale": 1.000000
        },
        "items": [

        ]
}
FelixKratz commented 8 months ago

Try to update to v2.20.0

aashish2057 commented 8 months ago

Updated to version 2.20.0 still same flickering with the minimal sketchybar as well

rhh4x0r commented 8 months ago

Just came across sketchybar for the first time and I'm getting flickering as well between space changes. Tried with sticky on and off, otherwise just default config.

Ventura 13.3.1

FelixKratz commented 8 months ago

I think with "Reduced Motion" there is nothing we can do about the flickering. But if thats not activated the windows should be on all spaces at the same time.

Could you test the current master and see if anything has changed about this problem (on Sonoma):

brew uninstall sketchybar
brew install sketchybar --head
brew services restart sketchybar

and then after testing go back to lastest release with:

brew uninstall sketchybar
brew install sketchybar
brew services restart sketchybar
aashish2057 commented 8 months ago

Just tested this with brew install sketchybar --head and still facing the same problem. Also I do not have "Reduce Motion" enabled. Let me know if you need any other details, want to help figure this out so I can start using sketchybar.

{
        "position": "top",
        "topmost": "off",
        "sticky": "on",
        "hidden": "off",
        "shadow": "off",
        "font_smoothing": "off",
        "blur_radius": 0,
        "margin": 0,
        "drawing": "on",
        "color": "0xffffffff",
        "border_color": "0xffff0000",
        "border_width": 0,
        "height": 40,
        "corner_radius": 0,
        "padding_left": 20,
        "padding_right": 20,
        "y_offset": 0,
        "clip": 0.000000,
        "image": {
                "value": "(null)",
                "drawing": "off",
                "scale": 1.000000
        },
        "items": [

        ]
}
FelixKratz commented 8 months ago

It seems sketchybar registers its windows as being sticky but for some reason the WindowServer does not respect this. So there has to be some special (rare) condition which causes this and I think it will have something to do with another system feature, because I am not able to properly reproduce this problem on my machine.

aashish2057 commented 8 months ago
FelixKratz commented 8 months ago

Ok that doesn't sound problematic at all... I will think a bit more about this problem, maybe I can come up with a solution. If you want and feel confident, you could try to check if the control flow reaches these lines (which are the ones that make the window sticky): https://github.com/FelixKratz/SketchyBar/blob/7d121d55e2e694c2cd9655dbdfdd70f9954e626c/src/window.c#L29-L32

rhh4x0r commented 8 months ago

Turning off Reduce motion worked for me. I also installed the head version with that as well.

aashish2057 commented 8 months ago

Ok that doesn't sound problematic at all... I will think a bit more about this problem, maybe I can come up with a solution. If you want and feel confident, you could try to check if the control flow reaches these lines (which are the ones that make the window sticky):

https://github.com/FelixKratz/SketchyBar/blob/7d121d55e2e694c2cd9655dbdfdd70f9954e626c/src/window.c#L29-L32

Not sure if I know how to do this, sorry if its a dumb question how would I check if the control flow reaches those lines?

aashish2057 commented 8 months ago

I am not sure if I did this right but attached a debugger and looks like it went inside the if statement?

Screenshot 2024-01-31 at 4 49 38 PM
aashish2057 commented 8 months ago

I tried on another machine and got the same flickering issue, not sure what I am doing wrong

FelixKratz commented 8 months ago

Could you maybe try to create a new user account on your mac where you try to run sketchybar? This way we will be able to determine if it is a software configuration issue (because the new account will have default settings) or a more general issue.

aashish2057 commented 8 months ago

Made a new user account, all default settings didn't do anything other than install brew before installing sketchybar, used the minimal sketchybar and on space switch got the same flickering.

FelixKratz commented 8 months ago

Ok, so I think I can now reproduce this problem. It is a bit subtle. The important part here is how exactly the spaces are changed. If the space is changed via a gesture on the trackpad, the sticky property works just as expected. If the space is changed via the keyboard shortcut "Move left a space" and "Move right a space" in "System Settings" -> "Keyboard Shortcuts" -> "Mission Control" -> "Mission Control" the sticky property also works as expected. However, if the keyboard shortcuts for "Switch to Desktop X" are used then there is flickering if the space change animations are enabled. For me those animations are disabled using yabai, which is why I could not reproduce the problem.

FelixKratz commented 8 months ago

There is a way to make the bar completely sticky on space change, i.e. it does not move at all during the space change animation. Maybe this would be a more robust approach.

aashish2057 commented 8 months ago

wow you are right I just tested this, I always use the mission control "switch to desktop x" to switch spaces and it flickers on that but I just tried it with "move left" and "move right" and there is no flickering at all

aashish2057 commented 8 months ago

There is a way to make the bar completely sticky on space change, i.e. it does not move at all during the space change animation. Maybe this would be a more robust approach.

This would be awesome

FelixKratz commented 8 months ago

Check it out (https://github.com/FelixKratz/SketchyBar/commit/6801874d0825b58150600a8666a3c1f89f07530c):

brew uninstall sketchybar
brew install sketchybar --head
brew services restart sketchybar

and once you want to go back to the current stable release (or the next one) run:

brew uninstall sketchybar
brew install sketchybar
brew services restart sketchybar

It would be very appreciated to get some testing done with this new way to draw the bar.

You need to enable the sticky property for it to use the new sticky feature.

JoseVarelaP commented 8 months ago

Hoping in to give this new patch a try, and yeah. Can confirm it now works with the "Switch To Desktop X" shortcuts. Doing this on "Reduced Motion" does still present the flicker problem but I'm not sure what can be done about that one.

https://github.com/FelixKratz/SketchyBar/assets/23246027/c9458c54-baf1-4e3b-a0bd-58537cc3b37b

aashish2057 commented 8 months ago

Yep can also confirm it is now working