asmvik / asmvik/yabai

Resize a floating window around its center

Open
#2,182 6 comments 1 reaction 0 assignees View on GitHub
suggestion
Dominant language
C
Stars
29.6k
Forks
750
PR merge metrics
No merged PRs in 30d

Description

I've been trying to add an effect to toggling a window into floating mode to make it a bit more obvious, and for that I wanted to resize the window around its center.

I tried this:

```bash
yabai -m query --windows id,frame --window |
jq -er '"yabai -m window \(.id) --toggle float --resize top_left:\(.frame.w/40):\(.frame.h/40) --resize bottom_right:\(.frame.w/-40):\(.frame.h/-40)"' |
sh -

# This executes something like this:
# yabai -m window 157365 --toggle float --resize top_left:19.775:25.9 --resize bottom_right:-19.775:-25.9
```

But then I quickly noticed that it doesn't achieve what I wanted it to, as yabai ignores the first `--resize` I passed in. Not sure whether that should be considered a bug.

From a user experience perspective, I don't actually want to express this as two resizes anchored at opposite corners. All I wanted to do is shrink my window by 20% around its center. It'd be nice to have a dedicated window command for this, for example:

```bash
# x and y are absolute values; positive numbers grow, negative numbers shrink the window
yabai -m window --resize center:x:y
```

Because then my script could just be this:

```bash
yabai -m query --windows id,frame --window |
jq -er '"yabai -m window \(.id) --toggle float --resize center:\(.frame.w/-20):\(.frame.h/-20)"' |
sh -
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the `yabai -m window --resize` command path and compare how repeated opposite-corner resizes are handled. Confirm the proposed `center:x:y` form resizes the window around its center, with positive values growing and negative values shrinking it, and verify the example command produces the requested effect.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli, desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.