i3: add smart resize
This commit is contained in:
parent
f490c76712
commit
de4637b618
|
@ -79,6 +79,12 @@ bindsym $mod+Shift+Down move down
|
|||
bindsym $mod+Shift+Up move up
|
||||
bindsym $mod+Shift+Right move right
|
||||
|
||||
# smart resize focused window
|
||||
bindsym $mod+Ctrl+Up exec ~/.local/bin/i3-smart-resize up
|
||||
bindsym $mod+Ctrl+Down exec ~/.local/bin/i3-smart-resize down
|
||||
bindsym $mod+Ctrl+Right exec ~/.local/bin/i3-smart-resize right
|
||||
bindsym $mod+Ctrl+Left exec ~/.local/bin/i3-smart-resize left
|
||||
|
||||
# split orientation
|
||||
bindsym $mod+q split toggle
|
||||
|
||||
|
@ -107,8 +113,8 @@ bindsym $mod+Shift+minus move scratchpad
|
|||
bindsym $mod+minus scratchpad show
|
||||
|
||||
#navigate workspaces next / previous
|
||||
bindsym $mod+Ctrl+Right workspace next
|
||||
bindsym $mod+Ctrl+Left workspace prev
|
||||
#bindsym $mod+Ctrl+Right workspace next
|
||||
#bindsym $mod+Ctrl+Left workspace prev
|
||||
|
||||
# Workspace names
|
||||
# to display names or symbols instead of plain workspace numbers you can use
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2016 Damien Riegel <damien.riegel@gmail.com>
|
||||
#
|
||||
# Licensed under the terms of the GNU GPL v3, or any later version.
|
||||
#
|
||||
# Resize the focused window depending on its position in the layout
|
||||
# Example: bindsym Left exec i3-smart-resize "Left"
|
||||
|
||||
import sys
|
||||
import i3ipc
|
||||
|
||||
DEFAULT_INCREMENT = "10 px or 10 ppt"
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
sys.exit(-1)
|
||||
key = sys.argv[1].lower()
|
||||
|
||||
if len(sys.argv) == 3:
|
||||
inc = sys.argv[2]
|
||||
else:
|
||||
inc = DEFAULT_INCREMENT
|
||||
|
||||
def is_at_top_edge(focused):
|
||||
workspace = focused.workspace()
|
||||
return focused.rect.y - focused.deco_rect.height == workspace.rect.y
|
||||
|
||||
def is_at_bottom_edge(focused):
|
||||
workspace = focused.workspace()
|
||||
return focused.rect.y + focused.rect.height == workspace.rect.y + workspace.rect.height
|
||||
|
||||
def is_at_left_edge(focused):
|
||||
workspace = focused.workspace()
|
||||
return focused.rect.x == workspace.rect.x
|
||||
|
||||
def is_at_right_edge(focused):
|
||||
workspace = focused.workspace()
|
||||
return focused.rect.x + focused.rect.width == workspace.rect.x + workspace.rect.width
|
||||
|
||||
|
||||
i3 = i3ipc.Connection()
|
||||
focused = i3.get_tree().find_focused()
|
||||
|
||||
if key == "up":
|
||||
if is_at_top_edge(focused):
|
||||
i3.command("resize shrink down %s" % (inc))
|
||||
else:
|
||||
i3.command("resize grow up %s" % (inc))
|
||||
elif key == "down":
|
||||
if is_at_bottom_edge(focused):
|
||||
i3.command("resize shrink up %s" % (inc))
|
||||
else:
|
||||
i3.command("resize grow down %s" % (inc))
|
||||
elif key == "right":
|
||||
if is_at_right_edge(focused):
|
||||
i3.command("resize shrink left %s" % (inc))
|
||||
else:
|
||||
i3.command("resize grow right %s" % (inc))
|
||||
elif key == "left":
|
||||
if is_at_left_edge(focused):
|
||||
i3.command("resize shrink right %s" % (inc))
|
||||
else:
|
||||
i3.command("resize grow left %s" % (inc))
|
||||
else:
|
||||
sys.exit(-1)
|
|
@ -2,6 +2,7 @@
|
|||
- [git submodule update --init --recursive, Updating submodules]
|
||||
|
||||
- create:
|
||||
- ~/.local/bin
|
||||
- ~/.zfunctions
|
||||
- ~/.config
|
||||
- ~/.config/beets
|
||||
|
@ -47,6 +48,8 @@
|
|||
~/.i3/config:
|
||||
path: config/i3/config
|
||||
force: true
|
||||
~/.local/bin/i3-smart-resize:
|
||||
path: config/i3/smart-resize
|
||||
~/.config/rofi/:
|
||||
glob: true
|
||||
path: config/rofi/**
|
||||
|
|
Loading…
Reference in New Issue