Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python3
- # Sets side (horizontal) gaps wide enough
- # that a single window in the middle would
- # have aspect ratio roughly that of a4 paper.
- import i3ipc
- # Initiate library.
- i3 = i3ipc.Connection()
- # Dimensions of focused workspace.
- dim_ws = i3.get_tree().find_focused().workspace().rect
- ws_width = dim_ws.width
- ws_height = dim_ws.height
- # Calculate approprite gap size (depends on monitor aspect ratio).
- gap_size = (ws_width - (ws_height / 1.3)) // 2
- # Toggle gaps.
- # Widescreen monitors turned sideways could cause problems.
- if gap_size > 0:
- i3.command('gaps horizontal current toggle {}'.format(gap_size))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement