Example #1
0
 def focus_workspace_number(self, group_context,
                            target_local_number: int) -> None:
     target_workspace_name, _ = self._derive_workspace(
         ws_names.WorkspaceGroupingMetadata(
             group=self._get_group_from_context(group_context),
             local_number=target_local_number))
     logger.debug('Derived workspace name: "%s"', target_workspace_name)
     self.i3_proxy.focus_workspace(target_workspace_name)
Example #2
0
 def move_to_workspace_number(self, group_context,
                              target_local_number: int) -> None:
     target_workspace_name, _ = self._derive_workspace(
         ws_names.WorkspaceGroupingMetadata(
             group=self._get_group_from_context(group_context),
             local_number=target_local_number))
     self.i3_proxy.send_i3_command(
         'move container to workspace "{}"'.format(target_workspace_name))
Example #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)
Example #4
0
 def _get_workspace_by_local_number(self, group: str,
                                    local_number: int) -> Tuple[str, bool]:
     # i3 commands like `workspace number n` will focus on an existing
     # workspace in another monitor if possible. To preserve this behavior,
     # we check the group workspaces in all monitors.
     group_to_all_workspaces = ws_names.get_group_to_workspaces(
         self.get_tree().workspaces())
     # Every workspace must have a unique (group, local_number) pair. This
     # tracks whether we found a workspace that conflicts with the given
     # (group, local_number).
     for workspace in group_to_all_workspaces.get(group, []):
         if ws_names.get_local_workspace_number(workspace) == local_number:
             return workspace.name, True
     return self._create_workspace_name(
         ws_names.WorkspaceGroupingMetadata(
             group=group, local_number=local_number)), False
Example #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)