Skip to content
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

The new notch handling mechanism is problematic for menubars such as simple-bar #1060

Closed
HeySora opened this issue Nov 22, 2021 · 9 comments
Closed

Comments

@HeySora
Copy link

HeySora commented Nov 22, 2021

The latest version of yabai can now calculate the notch height, and automatically put windows below it, which is super cool.

However, in my .yabairc, I have yabai -m config external_bar all:32:0.

The issue is that it creates a 32px gap below the notch for the bar, even though the bar fits alongside the notch.
I could set the gap to 0 and call it a day, however now external displays cannot show the bar at all.

Would it be possible to make an external_bar variant for notched displays? So I can set a gap of 0 for the MacBook display, and 32 for the external ones.

(Alternatively, I guess that subtracting the top value of external_bar with the notch height for notched displays would work too)

Thank you!

@nilsi
Copy link

nilsi commented Dec 7, 2021

I got the same problem. I constantly disconnect and work without a monitor and then the gap becomes too big on the MacBook screen.

@Devric
Copy link

Devric commented Dec 8, 2021

similar issue, is there a way to determine screen size and conditionally set the gap size?

@FelixKratz
Copy link

FelixKratz commented Dec 10, 2021

I know this is super hacky, but I coudn't really come up with something more elegant (you need to put the UUID of the notched display in the script).

Basically it decides between three states:

  • Only notched screen: $NOTCH_BAR spacing
  • External monitors and the notched screen: $NORMAL_BAR on the main display (assumes that the external monitor is the primary screen)
  • Clampshell mode (only external monitors): $NORMAL_BAR on all displays.

This should cover most use cases, except the somewhat rare and unusual cases with two external monitors and the notched screen as a third monitor, or external monitor setups with the notched screen as the main display

NOTCH_UUID="XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX"
NORMAL_BAR=32
NOTCH_BAR=0

yabai -m signal --add event=display_added action="if [[ \"\$(yabai -m query --displays | jq \".[\$YABAI_DISPLAY_ID].uuid\")\" =~ \"$NOTCH_UUID\" ]]; then yabai -m config external_bar main:$NORMAL_BAR:0; elif [[ \"\$(yabai -m query --displays | jq '.[].uuid')\" =~ \"$NOTCH_UUID\" ]]; then yabai -m config external_bar main:$NORMAL_BAR:0; else yabai -m config external_bar all:$NORMAL_BAR:0; fi"
yabai -m signal --add event=display_removed action="if [[ \"\$(yabai -m query --displays | jq \".[\$YABAI_DISPLAY_ID].uuid\")\" =~ \"$NOTCH_UUID\" ]]; then yabai -m config external_bar all:$NORMAL_BAR:0; elif [[ \"\$(yabai -m query --displays | jq '.[].uuid')\" =~ \"$NOTCH_UUID\" ]]; then yabai -m config external_bar all:$NOTCH_BAR:0; fi"

# global settings
if [[ "$(yabai -m query --displays | jq '.[].uuid')" =~ "$NOTCH_UUID" ]]; then if [ "$(yabai -m query --displays | jq length)" -gt "1" ]; then yabai -m config external_bar main:$NORMAL_BAR:0; else yabai -m config external_bar all:$NOTCH_BAR:0; fi else yabai -m config external_bar all:$NORMAL_BAR:0; fi

@jming422
Copy link

jming422 commented Jan 4, 2022

I've been tinkering around with this as well, but since I was used to keeping my laptop display as the main one, I messed around with other ways besides the above script, and what I ended up with seems to work well for me so far.

If your notched display is always the main one, and if you don't use "clampshell mode" / only external monitors, then the simplest solution is:

yabai -m config external_bar main:-30:0
yabai -m config top_padding  40

If you want all the cool features of @FelixKratz's solution except with the laptop screen always being the main display (so long as the laptop is open) then I've adapted their script to work for this case (this was written against b884717):

NOTCH_UUID="XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX"
NORMAL_BAR=32
NOTCH_BAR=0
NOTCH_OFFSET=$((NOTCH_BAR-NORMAL_BAR))

# Make the default space top padding equal to whatever your "normal" bar spacing is supposed to be
yabai -m config top_padding $NORMAL_BAR
# If the notched display is added, set external_bar to "main:$NOTCH_OFFSET:0". This will decrease the padding on the main (notched) screen
yabai -m signal --add event=display_added action="if [[ \"\$(yabai -m query --displays | jq \".[] | select(.id == \$YABAI_DISPLAY_ID) | .uuid\")\" =~ \"$NOTCH_UUID\" ]]; then yabai -m config external_bar \"main:$NOTCH_OFFSET:0\"; fi"
# If the notched display is removed, set external_bar to off so the main screen (which is now not notched) no longer has a padding decrease
yabai -m signal --add event=display_removed action="if [[ ! \"\$(yabai -m query --displays | jq '.[].uuid')\" =~ \"$NOTCH_UUID\" ]]; then yabai -m config external_bar off:0:0; fi"
# Apply those effects at startup
if [[ "$(yabai -m query --displays | jq '.[].uuid')" =~ "$NOTCH_UUID" ]]; then yabai -m config external_bar "main:$NOTCH_OFFSET:0"; else yabai -m config external_bar off:0:0; fi

This version is just a little simpler, and it seems to work in all the configurations mentioned above, except with the laptop screen as the main one whenever it's open. I find myself liking NORMAL_BAR=40 and NOTCH_BAR=10.

Note that both these methods use top_padding and external_bar, so it will clash with any other top_padding customizations you have.

@HeySora
Copy link
Author

HeySora commented Jan 12, 2022

All of these workarounds are great, but the best one for external bar users is still to stay on Yabai 3 😟

@koekeishiya Is it planned to re-adjust this behaviour to match how the previous versions of Yabai handle it?

I think the simplest way would be to apply a different external_bar value to notched displays, such as
(pseudo code) effective_external_bar_top = max(notch_height - external_bar.top, 0). That's how Yabai 3 currently handles bars, and that allows an user to simply provide their external_bar height as usual, regardless of whether the screen is notched or not!

In case someone needs an external bar below the notch, maybe an additional configuration could be done? such as
yabai -m config external_bar_below_notch on (off by default)

@somdoron
Copy link

somdoron commented Feb 7, 2022

Check out PR #1149, should solve the issue.

koekeishiya added a commit that referenced this issue Mar 16, 2022
@HeySora
Copy link
Author

HeySora commented Mar 17, 2022

Has been fixed by 271f908, thank you so much!! Congratulations for the release too.

@HeySora HeySora closed this as completed Mar 17, 2022
@jming422
Copy link

Hurray! 🎉 Yabai is much appreciated, grateful to delete my hacky workaround now 😄 , y'all rock

@Ahwxorg
Copy link

Ahwxorg commented Aug 10, 2023

I am asking here since I could not find any documentation on this (probably my fault).
How should I go about making this work in my setup? I have a docked place (home) where I use the laptop as a 3rd display with one display over TB3 and one display over HDMI. I have a 2023 M2 Pro MBP 14". I use SketchyBar and yabai. My configs are at https://github.com/Ahwxorg/dotfiles.

Tesohh added a commit to Tesohh/dotfiles that referenced this issue Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants