Advertisement
Guest User

Untitled

a guest
Apr 30th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import i3ipc
  4.  
  5. def main(args):
  6.     i3 = i3ipc.Connection()
  7.  
  8.     focused = i3.get_tree().find_focused().parent
  9.  
  10.     nodes_count = len(focused.nodes)
  11.     if len(focused.nodes) <= 1:
  12.         return 0
  13.  
  14.     new_size = int(100 / nodes_count)
  15.  
  16.     if focused.layout == 'splith':
  17.         ppt_x = new_size
  18.         ppt_y = 0
  19.     elif focused.layout == 'splitv':
  20.         ppt_x = 0
  21.         ppt_y = new_size
  22.     else:
  23.         return 1
  24.  
  25.     # We have to repeat the sizing of all nodes as many times as the number of nodes to get the nodes of the right size
  26.     for n in focused.nodes:
  27.         focused.command_children('resize set {ppt_x} ppt {ppt_y} ppt'.format(ppt_x=ppt_x, ppt_y=ppt_y))
  28.  
  29.     return 0
  30.  
  31.  
  32. if __name__ == '__main__':
  33.     import sys
  34.     sys.exit(main(sys.argv))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement