Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import i3ipc
- def main(args):
- i3 = i3ipc.Connection()
- focused = i3.get_tree().find_focused().parent
- nodes_count = len(focused.nodes)
- if len(focused.nodes) <= 1:
- return 0
- new_size = int(100 / nodes_count)
- if focused.layout == 'splith':
- ppt_x = new_size
- ppt_y = 0
- elif focused.layout == 'splitv':
- ppt_x = 0
- ppt_y = new_size
- else:
- return 1
- # 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
- for n in focused.nodes:
- focused.command_children('resize set {ppt_x} ppt {ppt_y} ppt'.format(ppt_x=ppt_x, ppt_y=ppt_y))
- return 0
- if __name__ == '__main__':
- import sys
- sys.exit(main(sys.argv))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement