Yabai: Move/resize named window

Created on 29 Jan 2020  路  7Comments  路  Source: koekeishiya/yabai

The window command only works with the focused window as far as I can see. Is it possible to resize and move a window by title?

Something like yabai -m window title="^MyTitle.*$" --resize=abs:1000:1000

question

All 7 comments

```sh
yabai -m query --windows |
jq '.[] | select(.title | test("^MyTitle.*$")).id' |
xargs -I{} yabai -m window {} --resize abs:1000:1000

OK, I figured it out:

WINDOW_SEL=$(yabai -m query --windows |jq '.[] | select (.title | contains("MyTitle")) | .id')
yabai -m window $WINDOW_SEL --resize abs:1000:1000

EDIT: Heh, you beat me to it. Thanks! Would have been nice with a built-in ID selector though :)

Note that your version fails if multiple windows match the query.

@dominiklohmann By the way, am I right to assume that I can't use --resize and --move in the same window message? Right now I have issue two separate commands.

By the way, am I right to assume that I can't use --resize and --move in the same window message? Right now I have issue two separate commands.

Yeah, that is correct. There is no technical reason for this, it's just how I happened to write the message parsing logic. Might revisit this idea in the future, but I don't think it's a big deal.
The overhead of having to issue two separate commands is not that important considering the fact that the macOS AX API will always be the bottleneck here.

Note that you don't need to issue the query twice:

yabai -m query --windows |
  jq '.[] | select(.title | test("zsh")).id' |
  xargs -L1 sh -c '
    yabai -m window $0 --toggle float &&
    yabai -m window $0 --resize abs:500:500
  '

@dominiklohmann I guess whether that is only one command or not is a matter of opinion ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chris-kahn picture chris-kahn  路  3Comments

brentd picture brentd  路  4Comments

Hum4n01d picture Hum4n01d  路  4Comments

zoenglinghou picture zoenglinghou  路  3Comments

koekeishiya picture koekeishiya  路  4Comments