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,30 +275,27 @@ 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.focused:
if container.nodes: style = 'foreground="#ffaf00"'
root = "" elif not container.window:
else: style = 'foreground="#6c98ee"'
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: else:
if container.focused: style = ''
style = 'foreground="#ffaf00"' if container.window:
elif not container.window: content = (f"{(container.window_class or '???').lower()}: "
style = 'foreground="#6c98ee"' f"{(container.window_title or '???')}")
else: elif container.type == 'workspace' and not container.nodes:
style = '' # Empty workspaces use workspace_layout, but when default,
if container.window: # this is layout...
content = (f"{(container.window_class or '???').lower()}: " layout = container.ipc_data['workspace_layout']
f"{(container.window_title or '???')}") if layout == "default":
else: layout = container.layout
content = f"({container.layout})" content = f"({layout})"
root = (f"<span {style}>" else:
f"{content.lower()}" content = f"({container.layout})"
"</span>") root = (f"<span {style}>"
f"{content.lower()}"
"</span>")
children = [] children = []
for child in container.nodes: for child in container.nodes:
if child == container.nodes[-1]: if child == container.nodes[-1]: