Yabai: Hidden window?

Created on 8 Jul 2019  路  2Comments  路  Source: koekeishiya/yabai

Is there a yabai command that can be used to hide or minimize a window and then bring it back as needed? I'd love to be able to have a floating terminal or browser window that I can use quickly and then disappear analogous to cmd-H, but with the ability to also bring it back w/the keyboard without having to cmd-tab to find it?

Thanks!

help wanted question

Most helpful comment

Some notes on the application switcher:

  • When you press cmd + tab and navigate to an application with a minimised window, press and hold alt while releasing cmd to deminimise windows of the focused application.
  • When you press cmd + tab and navigate to an application, press 1 without releasing cmd to invoke App Expos茅, which shows you all non-hidden, non-fullscreen and minimised windows.

Regarding your problem: using yabai, you could always float the window and move it to the bottom right corner to effectively hide it:

# grab the target window id (in this case of the focused window)
target_window="$(yabai -m query --windows --window | jq -re '.id')"

# float the target window and move it to somewhere that's far off to the bottom right
# (regardless of which window is focused at this point)
yabai -m window "${target_window}" --toggle float --move abs:10000:10000

# unfloat the target window to tile it again
yabai -m window "${target_window}" --toggle float

You can easily create a script for this to create some kind of collection of hidden windows per space.

Edit:

In general in macOS, hiding is done per-application and minimising is done per-window. If you want to hide an application and have a script unhide it, use the following:

target_app="iTerm2"

# hide app
osascript -e "tell application \"System Events\" to set visible of first process 卢" \
          -e "whose name is \"${target_app}\" to false"

# unhide app
osascript -e "tell application \"System Events\" to set visible of first process 卢" \
          -e "whose name is \"${target_app}\" to true"

All 2 comments

Some notes on the application switcher:

  • When you press cmd + tab and navigate to an application with a minimised window, press and hold alt while releasing cmd to deminimise windows of the focused application.
  • When you press cmd + tab and navigate to an application, press 1 without releasing cmd to invoke App Expos茅, which shows you all non-hidden, non-fullscreen and minimised windows.

Regarding your problem: using yabai, you could always float the window and move it to the bottom right corner to effectively hide it:

# grab the target window id (in this case of the focused window)
target_window="$(yabai -m query --windows --window | jq -re '.id')"

# float the target window and move it to somewhere that's far off to the bottom right
# (regardless of which window is focused at this point)
yabai -m window "${target_window}" --toggle float --move abs:10000:10000

# unfloat the target window to tile it again
yabai -m window "${target_window}" --toggle float

You can easily create a script for this to create some kind of collection of hidden windows per space.

Edit:

In general in macOS, hiding is done per-application and minimising is done per-window. If you want to hide an application and have a script unhide it, use the following:

target_app="iTerm2"

# hide app
osascript -e "tell application \"System Events\" to set visible of first process 卢" \
          -e "whose name is \"${target_app}\" to false"

# unhide app
osascript -e "tell application \"System Events\" to set visible of first process 卢" \
          -e "whose name is \"${target_app}\" to true"

There is an easier way to do that. Just drag and drop the window you want to minimize to another space. That's it!

Was this page helpful?
0 / 5 - 0 ratings