Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. #!/bin/python3
  2.  
  3. # Sets side (horizontal) gaps wide enough
  4. # that a single window in the middle would
  5. # have aspect ratio roughly that of a4 paper.
  6.  
  7. import i3ipc
  8.  
  9. # Initiate library.
  10. i3 = i3ipc.Connection()
  11.  
  12. # Dimensions of focused workspace.
  13. dim_ws = i3.get_tree().find_focused().workspace().rect
  14. ws_width = dim_ws.width
  15. ws_height = dim_ws.height
  16.  
  17. # Calculate approprite gap size (depends on monitor aspect ratio).
  18. gap_size = (ws_width - (ws_height / 1.3)) // 2
  19.  
  20. # Toggle gaps.
  21. # Widescreen monitors turned sideways could cause problems.
  22. if gap_size > 0:
  23.     i3.command('gaps horizontal current toggle {}'.format(gap_size))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement