Open eomdohyeon opened 2 years ago
I got close
#!/bin/bash
get_layout_type() {
out=$(yabai -m query --spaces --window mouse)
length=$(echo $out | jq length)
if [ $length -ne 1 ]; then
return -1
fi
echo $(echo $out | jq --raw-output ".[0].type")
}
yabai_move() {
direction=$1
layout=$(get_layout_type)
echo $direction $layout
if [ "$layout" = "stack" ]; then
case $direction in
north)
yabai -m window --warp stack.prev;;
south)
yabai -m window --warp stack.next;;
*)
:;;
esac
elif [ "$layout" = "bsp" ]; then
case $direction in
north)
yabai -m window --warp $direction || yabai -m space --rotate 270 && yabai -m space --balance x-axis;;
south)
yabai -m window --warp $direction || yabai -m space --rotate 90 && yabai -m space --balance x-axis;;
east | west)
yabai -m window --warp $direction || yabai -m window --toggle split && yabai -m space --balance y-axis;;
*)
:;;
esac
else
return -1
fi
}
What still doesn't work is:
+--------------+ +---------+----+
| a | | a | |
+ ------+------+ c move east |---------| |
| b | c | --> | b | c |
+ ------+------+ |---------| |
| d | | d | |
+--------------+ +---------+----+
It's harder when you can't really access the internal tree mechanics. @koekeishiya are there any plans/interest in exposing lower-level functions for tree manipulation?
Is there a way to work around "Currently, the window warp and swap commands require another window to exist in the moving position in order to move in that direction."?
It's harder when you can't really access the internal tree mechanics. @koekeishiya are there any plans/interest in exposing lower-level functions for tree manipulation?
I am not opposed to this, I just have not been able to come up with an intuitive syntax for accessing the tree from a CLI.
Is there a way to work around "Currently, the window warp and swap commands require another window to exist in the moving position in order to move in that direction."?
No there isn't really a way to do that currently.
A subset of what the i3 ipc offers is probably plenty: https://i3ipc-python.readthedocs.io/en/latest/con.html#i3ipc.Con
additionally, if we're just given the lower level tree manipulation API, it doesn't need to be super intuitive, and it's a lot easier for the community to build/maintain wrappers around it that end up being more intuitive
@koekeishiya takes some of the pressure of your shoulders!
I've been using i3wm on Linux for a long time and have been using yabai a lot since I switched to Mac. (Thank you so much for making the app.)
While using yabai, I felt that the way the windows move was different from the i3.
To move a window, i3 uses the 'move' command and yabai frequently uses the 'swap' and 'warp' commands.
Currently, the window warp and swap commands require another window to exist in the moving position in order to move in that direction.
Here's an example
Current behaviour: No window layout changes
The desired behavior is:
The same goes for below.
Current behaviour : No window layout changes
The desired behavior is:
Even with the current window swap and warp options, you can change from a left layout to a right layout form, but that's more work than expected.
This requires the right combination of commands like swap, warp, rotate, etc, and it's not that simple.
For users familiar with the layout of i3wm, intuitive Add the 'move' option for moving the window, or suggest the "yabai -m config layout i3" option.