From a2588342ffc450e888504a52fd165dcaa78b85b2 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 9 Jul 2021 20:35:17 +0200 Subject: [PATCH] i3-companion: fix logic for container layout Only empty workspaces are special. They follow `workspace_layout` value, except if `default`, in this case `layout`. --- bin/i3-companion | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/bin/i3-companion b/bin/i3-companion index d5bcef2..983b209 100755 --- a/bin/i3-companion +++ b/bin/i3-companion @@ -275,30 +275,27 @@ async def workspace_info(i3, event): if w.num == workspace.num] def format(container): - if container.type == "workspace": - if container.nodes: - root = "" - else: - if container.ipc_data['workspace_layout'] != "default": - layout = container.ipc_data['workspace_layout'] - else: - layout = container.layout - root = f"Empty workspace, with {layout} layout" + if container.focused: + style = 'foreground="#ffaf00"' + elif not container.window: + style = 'foreground="#6c98ee"' else: - if container.focused: - style = 'foreground="#ffaf00"' - elif not container.window: - style = 'foreground="#6c98ee"' - else: - style = '' - if container.window: - content = (f"{(container.window_class or '???').lower()}: " - f"{(container.window_title or '???')}") - else: - content = f"({container.layout})" - root = (f"" - f"{content.lower()}" - "") + style = '' + if container.window: + content = (f"{(container.window_class or '???').lower()}: " + f"{(container.window_title or '???')}") + elif container.type == 'workspace' and not container.nodes: + # Empty workspaces use workspace_layout, but when default, + # this is layout... + layout = container.ipc_data['workspace_layout'] + if layout == "default": + layout = container.layout + content = f"({layout})" + else: + content = f"({container.layout})" + root = (f"" + f"{content.lower()}" + "") children = [] for child in container.nodes: if child == container.nodes[-1]: