Skip to content

Hide all floating windows #1011

Answered by jasonvarga
jasonvarga asked this question in Q&A
Discussion options

You must be logged in to vote

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)

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by jasonvarga
Comment options

You must be logged in to vote
1 reply
@Bellavene
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants