Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Get yabai to respect ubersicht status bar height #454

Closed
nwaywood opened this issue Mar 24, 2020 · 6 comments
Closed

Get yabai to respect ubersicht status bar height #454

nwaywood opened this issue Mar 24, 2020 · 6 comments
Labels
suggestion Request for new feature or some form of enhancement

Comments

@nwaywood
Copy link

nwaywood commented Mar 24, 2020

Sorry if this is a noob question, but windows managed by yabai (in BSP mode) are covering up my status bar.

To illustrate the problem, I have reduced my ubersicht bar to just be a single example file, bar.jsx:

export const refreshFrequency = false

export const className = ` 
  z-index: -1;
  position: fixed;
  height: 30px;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  opacity: 0.9;
  background-color: #FF69B4;
`

export const render = () => (
    <div></div>
)

On an empty screen, you can see the whole bar (obviously):

image

But with windows open, they cover the status bar:

image

How do I make yabai respect the height of the status bar and not cover it up?

@nwaywood
Copy link
Author

FYI to anyone that comes across this, as a hack in the meantime I have just increased the top_padding to factor in the height of the status bar

@koekeishiya koekeishiya added the question Request for information or help, not an issue label Mar 30, 2020
@nwaywood
Copy link
Author

nwaywood commented Apr 2, 2020

Btw, the reason why this hack I am currently doing is insufficient is because it means to can't use the toggle padding command:

yabai -m space --toggle padding

@nwaywood nwaywood changed the title [Question] Get yabai to respect ubersicht status bar height Get yabai to respect ubersicht status bar height Apr 2, 2020
@koekeishiya
Copy link
Owner

koekeishiya commented Apr 12, 2020

There is no facility to do this in a way that is supported by --toggle padding yet. I can't think of a better solution than the one I used in chunkwm, which was basically having the following config options:

chunkc set custom_bar_enabled            0
chunkc set custom_bar_all_monitors       0
chunkc set custom_bar_offset_top         22
chunkc set custom_bar_offset_bottom      0
chunkc set custom_bar_offset_left        0
chunkc set custom_bar_offset_right       0

Do you know of other window managers that handle this type of functionality?

Edit:

This solution has a set of issues, as it is based on the assumption that there is only one bar running, and/or that it has the same dimensions on all displays. It is also either on one display or ALL displays etc, so there are a lot of theoretical cases that this type of config will not handle. This is also why I have not implemented this in yabai, because I don't think it is a good solution.

@nwaywood
Copy link
Author

Surely the main use case for the majority of users will be the bar having the same dimensions on all displays, no?

If that is the case, even if custom_bar_offset_top isn't a perfect solution I think it would be satisfactory for most, including me.

koekeishiya added a commit that referenced this issue Apr 23, 2020
@koekeishiya koekeishiya added addressed on master; not released Fixed upstream, but not yet released suggestion Request for new feature or some form of enhancement and removed question Request for information or help, not an issue labels Apr 23, 2020
@koekeishiya
Copy link
Owner

Implemented the following on master:

yabai -m config external_bar [<main|all|off>:<top_padding>:<bottom_padding>]

Specify top and bottom padding for a potential custom bar that you may be running.
main: Apply the given padding only to spaces located on the main display.
all: Apply the given padding to all spaces regardless of their display.
off: Do not apply any special padding.

@koekeishiya koekeishiya removed the addressed on master; not released Fixed upstream, but not yet released label May 1, 2020
@ben-toker
Copy link

Hey I encountered this and came up with my own solution that I think could help people. In my yabairc, I just execute the following shell script, which adjusts yabai's top padding depending on aspect ratio (weird scaling differences between 16:9 and native monitor, 16:10 so that's the only ones I have here but its easily modifiable).

Shell script (requires jq installation)

Step 1: install jq

brew install jq

Step 2: save the following shell script, call it whatever

#!/bin/bash

# Query the resolution of the active display
width=$(yabai -m query --displays --display | jq '.frame.w' | cut -d'.' -f1)
height=$(yabai -m query --displays --display | jq '.frame.h' | cut -d'.' -f1)

# Calculate the GCD of width and height to reduce the aspect ratio
gcd() {
    local a=$1
    local b=$2
    while [ "$b" -ne 0 ]; do
        local temp=$b
        b=$((a % b))
        a=$temp
    done
    echo $a
}

gcd_value=$(gcd $width $height)
aspect_width=$((width / gcd_value))
aspect_height=$((height / gcd_value))

# Set padding based on the calculated aspect ratio
if [[ "$aspect_width:$aspect_height" == "16:9" ]]; then
    yabai -m config top_padding 35  # 16:9 monitor
elif [[ "$aspect_width:$aspect_height" == "16:10" ]]; then
    yabai -m config top_padding 5   # 16:10 monitor
else
    yabai -m config top_padding 30  # Default for other aspect ratios
fi

Step 3: Put the path to the script in your .yabairc

An example of what my path looks like:
~/.config/scripts/displayresize.sh

There's probably a better, easier way to do this, but this is the best dynamic solution I could personally come up with. Hope this helps whoever finds this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
suggestion Request for new feature or some form of enhancement
Projects
None yet
Development

No branches or pull requests

3 participants