Adjust width of focused window with keyboard #1964
dungle-scrubs
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
You can use a combination of skhd and yabai's built in window resizing commands. Here's my skhd config that resizes the master window with # skhdrc #
# change master width
lalt + shift - h : ~/.config/skhd/resizeWindow.sh -h
lalt + shift - l : ~/.config/skhd/resizeWindow.sh -l
# change split height
lalt + shift - u : ~/.config/skhd/resizeWindow.sh -u
lalt + shift - d : ~/.config/skhd/resizeWindow.sh -d # resizeWindow.sh #
#!/bin/bash
WINDOW_RESIZE_AMOUNT=30
if [[ $1 = "-d" ]]; then
SPLIT_CHILD=$(yabai -m query --windows --window | jq '.["split-child"]')
if [[ $SPLIT_CHILD == "\"first_child\"" ]]; then
yabai -m window --resize bottom:0:$WINDOW_RESIZE_AMOUNT
fi
if [[ $SPLIT_CHILD == "\"second_child\"" ]]; then
yabai -m window --resize top:0:$WINDOW_RESIZE_AMOUNT
fi
elif [[ $1 = "-u" ]]; then
SPLIT_CHILD=$(yabai -m query --windows --window | jq '.["split-child"]')
if [[ $SPLIT_CHILD == "\"first_child\"" ]]; then
yabai -m window --resize bottom:0:-$WINDOW_RESIZE_AMOUNT
fi
if [[ $SPLIT_CHILD == "\"second_child\"" ]]; then
yabai -m window --resize top:0:-$WINDOW_RESIZE_AMOUNT
fi
elif [[ $1 = "-h" ]]; then
yabai -m window `yabai -m query --spaces --space | jq '."first-window"'` --resize right:-$WINDOW_RESIZE_AMOUNT:0
elif [[ $1 = "-l" ]]; then
yabai -m window `yabai -m query --spaces --space | jq '."first-window"'` --resize right:$WINDOW_RESIZE_AMOUNT:0
else
echo "Invalid flag entered."
fi |
Beta Was this translation helpful? Give feedback.
1 reply
-
@bustinbung thanks for the awesome script! I wanted to simplify it a bit and came up with the following: #!/bin/bash
WINDOW_RESIZE_AMOUNT=100
WINDOW=$(yabai -m query --windows --window)
SPLIT_TYPE=$(echo $WINDOW | jq -r '."split-type"')
resize() {
if [[ $SPLIT_TYPE == "vertical" ]]; then
echo "right:$1$WINDOW_RESIZE_AMOUNT:0"
else
echo "bottom:0:$1$WINDOW_RESIZE_AMOUNT"
fi
}
if [[ $1 = "decrease" ]]; then
yabai -m window --resize $(resize "-")
elif [[ $1 = "increase" ]]; then
yabai -m window --resize $(resize "")
else
echo "Invalid flag entered."
fi I call it from Alfred with However, I noticed that using it makes Yabai sluggish…do you see anything wrong with the script or do you think I should look elsewhere? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've just started using yabai and am really liking it so far. In my efforts to go mouseless, I find the urge to use my keyboard arrows plus a modifier to change the width of the window in focus by a few % per tap. Often, when I toss two windows on the screen at 50% each, I quickly realize the ideal percentages are a little different and want to quickly adjust, so I need to reach over for the mouse and drag.
Is this something that can currently be done? Or perhaps it would be a good feature candidate?
Cheers
Beta Was this translation helpful? Give feedback.
All reactions