Yabai: "Next Space/Monitor" with looping

Created on 2 Mar 2020  路  4Comments  路  Source: koekeishiya/yabai

Right now...

yabai -m display/space --move next
yabai -m display/space --focus next
yabai -m window --display/space next

All are unidirectional commands, and don't appear to 'loop back'. That is, if I have two displays or spaces, and tap the key twice (next and next), one might expect to end up where you started. I understand that if you're working in large linear space arrangements, it might be best to not accidentally wrap around, but I'd like the option to do so.

Is there a way to get a target like yabai -m display/space --move cycle which goes through the available spaces, and loops back? Or some other way to accomplish this looping?

Thanks!

question

Most helpful comment

You should be able to do this by relying on the exit code of the command. Something like the following for spaces:

yabai -m space --focus next || yabai -m space --focus first
and
yabai -m space --focus prev || yabai -m space --focus last

Same principle should apply for the other commands you mentioned as well.

All 4 comments

For what it's worth, 'recent' almost accomplishes this in a two-space paradigm, BUT it only works if you've already focused another space since Yabai was started.

You should be able to do this by relying on the exit code of the command. Something like the following for spaces:

yabai -m space --focus next || yabai -m space --focus first
and
yabai -m space --focus prev || yabai -m space --focus last

Same principle should apply for the other commands you mentioned as well.

Nice, this should be documented in the Wiki

Added some note to the wiki in the commands section.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hum4n01d picture Hum4n01d  路  4Comments

brentd picture brentd  路  4Comments

chris-kahn picture chris-kahn  路  3Comments

ThiagoFacchini picture ThiagoFacchini  路  4Comments

imjma picture imjma  路  3Comments