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

Set border options per space #211

Closed
benallan opened this issue Aug 15, 2019 · 4 comments
Closed

Set border options per space #211

benallan opened this issue Aug 15, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@benallan
Copy link

I tried setting border options for specific spaces but it seems like the settings were applied globally to all spaces.

yabai -m config --space 2 window_border_width 4
yabai -m config --space 2 window_border off

Maybe this isn't supported?

What I'd really like to do is disable borders for spaces where I always use fullscreen windows since I think it looks better, but keep borders on spaces where I have a bsp layout with mutliple windows.

@dominiklohmann
Copy link
Collaborator

This is not supported as can be seen below.

$ yabai -m config window_border off
$ yabai -m config --space 1 window_border on
$ yabai -m config --space 1 window_border
on
$ yabai -m config --space 2 window_border
on

You can, however, quite easily work around this: Create signals for the application_launched, window_created and space_changed events.

  • In the action for event=application_launched, query for all windows whose border is enabled, whose space index is one of the target spaces and whose PID is $YABAI_PROCESS_ID and toggle their border.
  • In the action for event=window_created, query for the window whose window id is $YABAI_WINDOW_ID and if its space index is one of the target spaces and its border is enabled, toggle its border.
  • In the action for event=space_changed, if the index of the space whose space id is$YABAI_SPACE_ID is one of the target spaces, query for all windows on that space whose border is enabled and toggle their border.

@benallan
Copy link
Author

Thanks a lot for the suggestions. I installed from HEAD to get the $YABAI_ env variables, and then realised that could I probably use a much simpler set up (avoiding any spaces logic), triggering on the window_resized signal:

  • If a window is zoom-fullscreen, then turn the border off.
  • If a window is not full screen, turn the border on.

The border toggle logic works fine, but it seems to cause a weird side effect:

  • Press zoom-fullscreen shortcut to fullscreen window: works ok.
  • Press shortcut again to disable fullscreen: works ok.
  • Press shortcut again to try to fullscreen window: fails. The window flickers and briefly changes to fullscreen size but immediately returns to normal size (not fullscreen). I inspect the window properties I see that zoom-fullscreen is set to 1.
  • Toggle twice more (-> normal -> fullscreen) and full screen works the next time.

So every second attempt to fullscreen the window fails while I'm using my signal settings. I wonder what might cause this?

yabairc:

yabai -m signal --add event=window_resized action="$HOME/bin/yabai_borders.sh"

yabai_borders.sh:

#!/bin/bash

is_fullscreen=$(yabai -m query --windows --window "$YABAI_WINDOW_ID" | jq -re '.["zoom-fullscreen"]')
has_border=$(yabai -m query --windows --window "$YABAI_WINDOW_ID" | jq -re '.["border"]')

if [[ "$is_fullscreen" -eq "1" ]]; then
  if [[ "$has_border" -eq "1" ]]; then
    yabai -m window "$YABAI_WINDOW_ID" --toggle border
  fi
else
  if [[ "$has_border" -eq "0" ]]; then
    yabai -m window "$YABAI_WINDOW_ID" --toggle border
  fi
fi

@koekeishiya
Copy link
Owner

Toggling border would cancel the windows zoom. Fixed on master.

@koekeishiya koekeishiya added addressed on master; not released Fixed upstream, but not yet released bug Something isn't working labels Aug 17, 2019
@benallan
Copy link
Author

Works great now, thanks a lot!

@koekeishiya koekeishiya removed the addressed on master; not released Fixed upstream, but not yet released label Sep 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants