Hide all floating windows #1011
-
I'd like to be able to set up a keyboard shortcut that'll hide all floating windows, leaving my managed ones visible. This sounds like something that should be possible with Yabai by querying windows and using a loop or two. If anyone has any ideas that'd be great. Otherwise I'll post back here if I work it out myself. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Not pretty, but I was able to write this in PHP since it's what I'm familiar with. I went with this: <?php
$windows = json_decode(shell_exec('/opt/homebrew/bin/yabai -m query --windows'));
$windows = array_filter($windows, fn ($window) => $window->floating);
$windows = array_map(fn ($window) => $window->id, $windows);
foreach ($windows as $id) {
shell_exec("/opt/homebrew/bin/yabai -m window $id --minimize");
} Then set up a shortcut to run that file. I use Hammerspoon. hs.hotkey.bind('cmd alt ctrl', 'h', function()
hs.task.new('/opt/homebrew/bin/php', nil, {'/Users/jason/.dotfiles/yabai/hide-floating-windows.php'}):start()
end) |
Beta Was this translation helpful? Give feedback.
-
+1 for using php. I really love shell scripting in php as it’s much more elegant than Perl or Python. |
Beta Was this translation helpful? Give feedback.
-
Here’s a one-liner with jq: yabai -m query --windows | jq '.[] | select(."is-floating"==true) | .id' | while read id; do yabai -m window $id --minimize; done Add it to # Hide floating windows
alt - h : yabai -m query --windows \
| jq '.[] | select(."is-floating"==true) | .id' \
| while read id; do yabai -m window $id --minimize; done |
Beta Was this translation helpful? Give feedback.
Not pretty, but I was able to write this in PHP since it's what I'm familiar with. I went with this:
Then set up a shortcut to run that file. I use Hammerspoon.