koekeishiya / yabai

A tiling window manager for macOS based on binary space partitioning
MIT License
23.31k stars 642 forks source link

How to float window/pop-up based on app and title? #2375

Closed fcaraujo closed 2 months ago

fcaraujo commented 2 months ago

Hey,

Can someone please help me figure out how to float this Bitwarden authentication pop-up window? (preferably vertically/horizontally centralized if possible 🙂)

I'm running yabai-v7.1.1 on macOS Sonoma 14.6 (23G80).

This is what I currently have: image

This is roughly my target:

image

I queried it and got the following (to ensure I have a window app/title that matches my attempts):

{
        "id":2836,
        "pid":624,
        "app":"Google Chrome",
        "title":"Bitwarden",
        "scratchpad":"",
        "frame":{
                "x":415.0000,
                "y":387.0000,
                "w":613.0000,
                "h":271.0000
        },
        "role":"AXWindow",
        "subrole":"AXStandardWindow",
        "root-window":true,
        "display":1,
        "space":1,
        "level":0,
        "sub-level":0,
        "layer":"normal",
        "sub-layer":"normal",
        "opacity":1.0000,
        "split-type":"none",
        "split-child":"none",
        "stack-index":0,
        "can-move":true,
        "can-resize":true,
        "has-focus":false,
        "has-shadow":true,
        "has-parent-zoom":false,
        "has-fullscreen-zoom":false,
        "has-ax-reference":true,
        "is-native-fullscreen":false,
        "is-visible":true,
        "is-minimized":false,
        "is-hidden":false,
        "is-floating":true,
        "is-sticky":false,
        "is-grabbed":false
}

And I tried a couple of rules/signals without success:

yabai -m rule --add app="Google Chrome" title="Bitwarden" manage=off
...
yabai -m rule --add app="Google Chrome" title="Bitwarden" manage=on grid=10:10:1:1:8:8 border=on sticky=on layer=above
...
yabai -m signal --add app='Google Chrome' event='window_title_changed' \
  action="yabai -m rule --add label=$(uuidgen) app='Google Chrome' title='Bitwarden' manage=off"'
...
yabai -m signal --add app='Google Chrome' event='window_created' \
  action="yabai -m rule --add label=$(uuidgen) app='Google Chrome' title='Bitwarden' manage=off"'

Thank you

koekeishiya commented 2 months ago

You need to use --apply instead of --add if you want to apply rules to existing windows from a signal. Try the following instead: yabai -m signal --add app='Google Chrome' event='window_title_changed' action="yabai -m rule --apply app='Google Chrome' title='Bitwarden' manage=off grid=10:10:3:3:6:6"

fcaraujo commented 2 months ago

@koekeishiya really appreciated it; it worked like a charm! By the way thanks for also clarifying the bits I missed.

I just tinkered a lil bit the grid config and that's what I have 🎉:

image

For posterity (and to help the next folks searching for light):

yabai -m signal --add app='Google Chrome' event='window_title_changed' \
  action="yabai -m rule --apply app='Google Chrome' title='Bitwarden' manage=off grid=12:12:4:4:4:4"

Cheers!