Reputation: 25
I have a little troubles with binding resize mode. I have the following resize config
set $resize_delta 2
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the window’s width.
# Pressing right will grow the window’s width.
# Pressing up will shrink the window’s height.
# Pressing down will grow the window’s height.
bindsym h resize shrink width $resize_delta px or $resize_delta ppt
bindsym j resize grow height $resize_delta px or $resize_delta ppt
bindsym k resize shrink height $resize_delta px or $resize_delta ppt
bindsym l resize grow width $resize_delta px or $resize_delta ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width $resize_delta px or $resize_delta ppt
bindsym Down resize grow height $resize_delta px or $resize_delta ppt
bindsym Up resize shrink height $resize_delta px or $resize_delta ppt
bindsym Right resize grow width $resize_delta px or $resize_delta ppt
# back to normal: Enter or Escape or $mod+r
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "default"
}
I want to have resize by direction, if i press h
i want to increase/decrease depends on window position, if it's in right corner pressing h
would be increase width, if in left corner would be decrease width, can i do this? Same resize by direction you can check in tmux,windows terminal. For tmux you need to set following:
# change the window size
bind -r H resize-pane -L 10
bind -r J resize-pane -D 10
bind -r K resize-pane -U 10
bind -r L resize-pane -R 10
Upvotes: 0
Views: 328
Reputation: 11
I've made a python script some time ago to do just that. It's very terrible and hacky, still, it works most of the time. Here's what you'll need:
$npm install i3ipc
or $sudo pacman -S python-i3ipc
if you're on arch)import sys
from i3ipc import Connection
def get_data(current):
rightmost = True
bottommost = True
while True:
if current.type == "workspace":
return rightmost, bottommost
parent = current.parent
children = parent.nodes
for i, child in enumerate(children):
if child.id == current.id:
current_i = i
if current_i != len(children) - 1:
match parent.layout:
case "splith":
rightmost = False
case "splitv":
bottommost = False
current = parent
def main():
direction = sys.argv[1]
amount = sys.argv[2]
i3 = Connection()
tree = i3.get_tree()
focused = tree.find_focused()
rightmost, bottommost = get_data(focused)
match direction:
case "left":
if rightmost:
i3args = "grow left"
else:
i3args = "shrink right"
case "right":
if rightmost:
i3args = "shrink left"
else:
i3args = "grow right"
case "up":
if bottommost:
i3args = "grow up"
else:
i3args = "shrink down"
case "down":
if bottommost:
i3args = "shrink up"
else:
i3args = "grow down"
i3.command(f"resize {i3args} {amount} px")
if __name__ == "__main__":
main()
bindsym $mod+Control+Left exec python <PATH/TO/YOUR/SCRIPT>.py left 50
bindsym $mod+Control+Down exec python <PATH/TO/YOUR/SCRIPT>.py down 50
bindsym $mod+Control+Up exec python <PATH/TO/YOUR/SCRIPT>.py up 50
bindsym $mod+Control+Right exec python <PATH/TO/YOUR/SCRIPT>.py right 50
Upvotes: 1