How to use move_workspace method in tempest

Best Python code snippet using tempest_python

executable_reflow-workspaces.py

Source:executable_reflow-workspaces.py Github

copy

Full Screen

...42 """43 Returns the list of outputs sorted from left to right based on geometry.44 """45 return sorted(outputs, key=lambda output: output.rect.x)46def move_workspace(workspace, output):47 """48 Move a workspace to an output.49 @param workspace: the workspace to move50 @param output: the destination output51 """52 i3.command("workspace %s" % workspace)53 i3.command("move workspace to output %s" % output)54def _reflow(workspaces, outputs):55 """56 Distribute workspaces evenly across outputs.57 @param workspaces: is a list of workspace names i.e. ['1', '2', '3']58 @param outputs: is a list of output names i.e. ['VGA1', 'DP1']59 """60 if len(workspaces) < 2:61 # if there's 1 or 0 workspaces, apply initial configuration62 _reflow_initial_configuration(outputs)63 return64 i = 065 j = 166 workspaces_per_output = math.ceil(float(len(workspaces)) / len(outputs))67 while j < len(workspaces) + 1:68 workspace = workspaces[j - 1]69 output = outputs[i]70 print(("%s goes on %s" % (workspace, output)))71 move_workspace(workspace, output)72 if math.fmod(j, workspaces_per_output) == 0 and i < len(outputs) - 1:73 i += 174 j += 175def _reflow_initial_configuration(outputs):76 """77 Just sort workspaces per output numerically78 @param outputs: is a list of output names i.e. ['VGA1', 'DP1']79 """80 print("applying initial configuration")81 for index, output in zip(range(len(outputs)), outputs):82 workspace = str(index + 1)83 print(("%s goes on %s" % (workspace, output)))84 move_workspace(workspace, output)85def reflow_from_left_to_right():86 """87 Evenly distribute workspaces from left to right outputs.88 """89 # get all the things90 workspaces = i3.get_workspaces()91 outputs = [output for output in i3.get_outputs() if output.active]92 focused_workspace = get_focused_workspace(workspaces)93 non_empty_workspace_names = get_non_empty_workspaces()94 # sort and extract the the ids (names)95 workspace_names = get_names(workspaces_sorted_by_number(workspaces))96 output_names = get_names(outputs_from_left_to_right(outputs))97 focused_workspace_name = focused_workspace.name if focused_workspace else None98 sorted_non_empty_workspace_names = [99 w for w in workspace_names if w in non_empty_workspace_names100 ]101 print(("workspaces found: %s" % ", ".join(workspace_names)))102 print(("non empty workspaces: %s" % ", ".join(non_empty_workspace_names)))103 print(("outputs found: %s" % ", ".join(output_names)))104 print(("focused workspace: %s" % focused_workspace_name))105 # move all workspaces to first output before reflowing106 for w in workspace_names:107 move_workspace(w, output_names[0])108 # reflow workspaces109 _reflow(sorted_non_empty_workspace_names, output_names)110 # focus back the workspace that was focused before reflowing111 if focused_workspace_name in non_empty_workspace_names:112 i3.command("workspace %s" % focused_workspace_name)113if __name__ == "__main__":...

Full Screen

Full Screen

dmenu_utils.py

Source:dmenu_utils.py Github

copy

Full Screen

2import re3import sys4import i35import pprint6def move_workspace(source, dest):7 i3.command('rename', 'workspace "%s" to "%s"' % (str(source), str(dest)))8def switch_to_workspace(target):9 i3.command('workspace "%s"' % (str(target)))10def move_window_to_workspace(target, follow=False):11 i3.command('move', 'container to workspace "%s"' % (str(target)))12 if follow: switch_to_workspace(target)13def move_window_to_output(target):14 i3.command('move', 'window to output "%s"' % (str(target)))15def get_workspaces():16 data = i3.get_workspaces()17 data = { int(item['name']): item for item in data if is_valid(item) }18 return data19def is_valid(item):20 try:21 garbage = int(item['name'])22 return True23 except ValueError:24 return False25def move_to_workspace_with_push(source, target, workspaces):26 print(source)27 end_of_the_line = max(workspaces.keys())+128 if target in workspaces: # swap29 move_workspace(target,end_of_the_line)30 move_workspace(source,target)31 move_workspace(end_of_the_line,source)32 else:33 move_workspace(source,target)34def get_current_workspace(workspaces):35 for (k,v) in workspaces.items():36 if v['focused']: return (k,v)37 return (None,None)38 #return [k for k,v in workspaces if v['visible']][0]39def move_window_to_next_monitor(current_w,workspaces):40 monitor = current_w['output']41 monitors = sorted(set([v['output'] for (k,v) in workspaces.items()]))42 index = monitors.index(monitor)43 output = monitors[(index+1) % len(monitors)]44 move_window_to_output(output)45def get_monitor_ids(target_monitor,workspaces):46 return sorted([k for (k,v) in workspaces.items() if v['output'] == target_monitor])47# returns list item at index, or null if index is invalid...

Full Screen

Full Screen

order-workspaces.py

Source:order-workspaces.py Github

copy

Full Screen

...12 for ws in workspaces:13 if ws.num == ws_num - 1:14 return ws.output == SECONDARY_SCREEN15 return True16def move_workspace(i3, ws_name, output=SECONDARY_SCREEN):17 i3.command('workspace "%s"' % ws_name)18 i3.command('move workspace to output "%s"' % output)19def on_workspace_rename(i3, event):20 if should_be_moved(i3, event.current.num):21 move_workspace(i3, event.current.name)22if __name__ == '__main__':23 time.sleep(0.2)24 i3 = i3ipc.Connection()25 primary_screen = ''26 for output in i3.get_outputs():27 if output['name'] == 'HDMI1' or output['name'] == 'VGA1':28 primary_screen = output['name']29 break30 if not primary_screen:31 sys.exit()32 current_focus = i3.get_tree().find_focused().workspace().name33 workspaces = []34 for ws in i3.get_workspaces():35 workspaces.append((ws.num, ws.name))36 workspaces.sort()37 move_remaining = False38 for i in range(len(workspaces)):39 if move_remaining or (workspaces[i][0] > FLIP_POINT and workspaces[i - 1][0] < workspaces[i][0] - 1):40 move_remaining = True41 move_workspace(i3, workspaces[i][1])42 else:43 move_workspace(i3, workspaces[i][1], primary_screen)44 i3.command('workspace "%s"' % current_focus)45 i3.on('workspace::rename', on_workspace_rename)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful