def dispatch_i3msg_com( command: str, data: Location = Location(1189, 652)) -> list: """Internal function used to dispatch specific command strings to i3-ipc. Data may also be a string.""" dispatcher = { # Dictionary of commands to execute with i3 comx "resize": lambda *d: i3.resize("set", d[0], d[1]), "move": lambda *d: i3.move("window", "position", d[0], d[1]), "float": lambda *d: i3.floating("enable"), "reset": lambda *d: (i3.resize("set", f"{d[0]}ppt", f"{d[0]}ppt") and i3.move( "window", " position", "center")), "custom": (lambda *d: i3.resize("set", d[0], d[0]) and i3.move( "window", "position", "center")), } if isinstance(data, str): return dispatcher[command](data) elif isinstance(data, Location): w = str(data.width) if data.width > 0 else "0" h = str(data.height) if data.height > 0 else "0" return dispatcher[command](w, h)
def make_focused(current_id): """Make the focused window floating, set its dimensions and position. """ i3.focus(con_id=current_id) i3.floating('enable') i3.resize(f'set {WIDTH} {HEIGHT}') i3.move('position center')
def resize((width, height)): rect = i3.filter(focused = True)[0]["rect"] delta_w = (width - rect["width"]) / 19 delta_h = (height - rect["height"]) / 19 print "Will resize by", (delta_w, delta_h) if delta_w < 0: i3.resize("shrink", "width", "{x} px or {x} ppt".format(x = -delta_w)) else: i3.resize("grow", "width", "{x} px or {x} ppt".format(x = delta_w)) if delta_h < 0: i3.resize("shrink", "height", "{x} px or {x} ppt".format(x = -delta_h)) else: i3.resize("grow", "height", "{x} px or {x} ppt".format(x = delta_h))
def make_float(current_id): i3.focus(con_id=current_id) i3.floating('enable') i3.resize('set 1000 1000') i3.move('position center')
i3.focus(con_id=workspace['id']) i3.layout('splitv') for leaf in left: revisualize(leaf, workspace['name']) first_right = right.pop(0) revisualize(first_right, workspace['name']) i3.move('right') i3.split('v') i3.focus(con_id=first_right['id']) for leaf in right: revisualize(leaf, workspace['name']) for leaf in extra: revisualize(leaf, workspace['name']) i3.move('down') shrinkable = True while shrinkable: response = i3.resize('shrink height 10 px or 10 ppt') shrinkable = response[0] print(leaf['rect']['height']) # # #for leaf in leaves: # i3.focus(con_id=leaf['id']) # i3.move('to workspace ' + workspace_name) # i3.floating('disable')
#!/usr/bin/env python import i3 import sys pct = float(sys.argv[1]) c = i3.filter(nodes=[], focused=True)[0] ws = i3.get_workspaces() for el in ws: if el['focused'] and el['visible']: cur = el w = float(cur['rect']['width']) h = float(cur['rect']['height']) print "workspace width is {}".format(w) p = w/100.0 print "p {}".format(p) cur_pct = (float(c['rect']['width'])/w) * 100.0 diff = pct - cur_pct print "diff {}".format(diff) pix = str(int(abs(diff)*p)) diffp = int(abs(pct - cur_pct)) if diff > 0: print "ingrandisci di {} px".format(pix) i3.resize("grow width " + pix + " px or " + str(diffp) + " ppt" ); else: print "rimpicciolisci di {} px".format(pix) i3.resize("shrink width " + pix + " px or " + str(diffp) + " ppt" );
i3.focus(con_id=base[abscissa]['id']) revisualize(stack[idx], workspace['name']) base[abscissa] = stack[idx] for leaf in extra: revisualize(leaf, workspace['name']) i3.move('down') workspace_after = i3.filter(id=workspace['id'])[0] cssh_container = None for node in reversed(workspace_after['nodes']): for resize_iter in range(0,50): if node['name'] is None and len(node['nodes']) > 0: i3.focus(con_id=node['id']) i3.resize('grow up 40 px') else: i3.focus(con_id=node['id']) i3.resize('shrink up 40 px') for node in extra: if 'CSSH ' in node['name']: i3.focus(con_id=node['id']) #pp = pprint.PrettyPrinter(indent=4) #pp.pprint(workspace_after) #for node in workspace_after['nodes']: # print(len(node['nodes'])) # #for i in range(0,4): # for leaf in reversed(extra):
def make_float(current_id): size = get_size() i3.focus(con_id=current_id) i3.floating('enable') i3.resize('set {} {}'.format((size + int(size*.56)), size)) i3.move('position center')
#!/usr/bin/python import i3 import sys targetwidth = float(sys.argv[1]) # get currently focused window current=i3.filter(nodes=[], focused=True) currentsize = current[0]['percent'] * 100; d = int(targetwidth - currentsize) if d>0: i3.resize("grow width" + str(d) + " px or " + str(d) + " ppt"); else: i3.resize("shrink width" + str(-d) + " px or " + str(-d) + " ppt");
#!/usr/bin/env python import i3 import pprint pp = pprint.PrettyPrinter(indent=4) currentWindow = i3.filter(focused=True)[0] i3.focus(con_id=currentWindow['id']) pp.pprint(currentWindow) height = currentWindow['rect']['height'] print(height) print(height - 235) #i3.resize('shrink height 10') i3.resize('grow height 1000')
def make_float(current_id): size = get_size() i3.focus(con_id=current_id) i3.floating('enable') i3.resize('set {} {}'.format((size + int(size * .56)), size)) i3.move('position center')