def _get_group_from_context(self, group_context): group_context = group_context or ActiveGroupContext() focused_monitor_name = self.i3_proxy.get_focused_monitor_name() group_to_monitor_workspaces = ws_names.get_group_to_workspaces( self.i3_proxy.get_monitor_workspaces(focused_monitor_name)) target_group = group_context.get_group_name( self.get_tree(), group_to_monitor_workspaces) logger.info('Context group: "%s"', target_group) return target_group
def get_window_icon(self, window: i3ipc.Con) -> str: for rule in self.rules: icon = rule.match(window) if icon is not None: return icon logger.info( 'No icon specified for window with class: "%s", instance: ' '"%s", title: "%s", name: "%s"', window.window_class, window.window_instance, window.window_title, window.name) return self.config['default_icon']
def get_unique_marked_workspace(self, mark) -> Optional[i3ipc.Con]: workspaces = self.get_tree().find_marked(mark) if not workspaces: logger.info('Didn\'t find workspaces with mark: %s', mark) return None if len(workspaces) > 1: logger.warning( 'Multiple workspaces marked with %s, using first ' 'one', mark) return workspaces[0]
def send_i3_command(self, command: str) -> None: if self.dry_run: log_prefix = '[dry-run] would send' else: log_prefix = 'Sending' logger.info("%s i3 command: '%s'", log_prefix, command) if not self.dry_run: reply = self.i3_connection.command(command)[0] if not reply.success: logger.warning('i3 command error: %s', reply.error)
def get_window_icon(window: i3ipc.Con) -> str: for regex, icon in WINDOW_INSTANCE_REGEX_TO_ICON.items(): if window.window_instance and regex.match(window.window_instance): return icon for regex, icon in WINDOW_CLASS_REGEX_TO_ICON.items(): if window.window_class and regex.match(window.window_class): return icon logger.info( 'No icon specified for window with window class: "%s", instance: ' '"%s", name: "%s"', window.window_class, window.window_instance, window.name) return DEFAULT_ICON