Ejemplo n.º 1
0
 def organize_workspace_groups(self,
                               workspace_groups: OrderedWorkspaceGroups,
                               monitor_name: Optional[str] = None) -> None:
     if monitor_name is None:
         monitor_name = self.i3_proxy.get_focused_monitor_name()
     monitor_index = self.i3_proxy.get_monitor_index(monitor_name)
     group_to_all_workspaces = ws_names.get_group_to_workspaces(
         self.get_tree().workspaces())
     for group_index, (group, workspaces) in enumerate(workspace_groups):
         logger.debug('Organizing workspace group: "%s" in monitor "%s"',
                      group, monitor_name)
         local_numbers = ws_names.compute_local_numbers(
             workspaces, group_to_all_workspaces.get(group, []),
             self.config['renumber_workspaces'])
         for workspace, local_number in zip(workspaces, local_numbers):
             ws_metadata = ws_names.parse_name(workspace.name)
             ws_metadata.group = group
             ws_metadata.local_number = local_number
             ws_metadata.global_number = ws_names.compute_global_number(
                 monitor_index, group_index, local_number)
             dynamic_name = ''
             # Add window icons if needed.
             if self.config['icons']['enable'] and (
                     self.config['icons']['enable_all_groups']
                     or group_index == 0):
                 dynamic_name = self.icons_resolver.get_workspace_icons(
                     workspace)
             ws_metadata.dynamic_name = dynamic_name
             new_name = ws_names.create_name(ws_metadata)
             self.i3_proxy.rename_workspace(workspace.name, new_name)
             workspace.name = new_name
Ejemplo n.º 2
0
def create_workspace(
        workspace_id: int,
        ws_metadata: workspace_names.WorkspaceGroupingMetadata) -> i3ipc.Con:
    workspace = mock.create_autospec(i3ipc.Con)
    workspace.id = workspace_id
    if ws_metadata.group is None:
        ws_metadata.group = ''
    workspace.name = workspace_names.create_name(ws_metadata)
    return workspace
Ejemplo n.º 3
0
 def _create_new_active_group_workspace_name(
         self, monitor_name: str, target_group: str) -> i3ipc.Con:
     local_number = self._find_free_local_number(target_group)
     global_number = ws_names.compute_global_number(
         monitor_index=self.i3_proxy.get_monitor_index(monitor_name),
         group_index=0,
         local_number=local_number)
     ws_metadata = ws_names.WorkspaceGroupingMetadata(
         group=target_group,
         global_number=global_number,
         local_number=local_number)
     return ws_names.create_name(ws_metadata)
Ejemplo n.º 4
0
 def _create_workspace_name(
         self, metadata: ws_names.WorkspaceGroupingMetadata) -> str:
     focused_monitor_name = self.i3_proxy.get_focused_monitor_name()
     monitor_index = self.i3_proxy.get_monitor_index(focused_monitor_name)
     group_to_monitor_workspaces = ws_names.get_group_to_workspaces(
         self.i3_proxy.get_monitor_workspaces(focused_monitor_name))
     group_index = ws_names.get_group_index(metadata.group,
                                            group_to_monitor_workspaces)
     metadata = copy.deepcopy(metadata)
     metadata.global_number = ws_names.compute_global_number(
         monitor_index, group_index, (metadata.local_number))
     return ws_names.create_name(metadata)
Ejemplo n.º 5
0
 def _create_new_active_group_workspace_name(
         self, monitor_name: str, target_group: str) -> i3ipc.Con:
     group_to_all_workspaces = ws_names.get_group_to_workspaces(
         self.get_tree().workspaces())
     used_local_numbers = ws_names.get_used_local_numbers(
         group_to_all_workspaces.get(target_group, []))
     local_number = next(
         iter(ws_names.get_lowest_free_local_numbers(1,
                                                     used_local_numbers)))
     global_number = ws_names.compute_global_number(
         monitor_index=self.i3_proxy.get_monitor_index(monitor_name),
         group_index=0,
         local_number=local_number)
     ws_metadata = ws_names.WorkspaceGroupingMetadata(
         group=target_group,
         global_number=global_number,
         local_number=local_number)
     return ws_names.create_name(ws_metadata)