i3-companion: fix logic for container layout

Only empty workspaces are special. They follow `workspace_layout`
value, except if `default`, in this case `layout`.
This commit is contained in:
Vincent Bernat 2021-07-09 20:35:17 +02:00
parent 8490fed7bc
commit a2588342ff

View file

@ -275,16 +275,6 @@ async def workspace_info(i3, event):
if w.num == workspace.num] if w.num == workspace.num]
def format(container): 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"
else:
if container.focused: if container.focused:
style = 'foreground="#ffaf00"' style = 'foreground="#ffaf00"'
elif not container.window: elif not container.window:
@ -294,6 +284,13 @@ async def workspace_info(i3, event):
if container.window: if container.window:
content = (f"{(container.window_class or '???').lower()}: " content = (f"{(container.window_class or '???').lower()}: "
f"{(container.window_title or '???')}") 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: else:
content = f"({container.layout})" content = f"({container.layout})"
root = (f"<span {style}>" root = (f"<span {style}>"