Navigate and manipulate the i3 layout tree
masterThe window manager's layout is represented by a tree of Con (container) objects. You can retrieve the root container using get_tree(), find specific windows by class or focus status, and issue commands directly to specific containers.
# get_tree() returns the root container
tree = await i3.get_tree()
# get some information about the focused window
focused = tree.find_focused()
print(f'Focused window: {focused.name}')
workspace = focused.workspace()
print(f'Focused workspace: {workspace.name}')
# focus firefox and set it to fullscreen mode
ff = tree.find_classed('Firefox')[0]
await ff.command('focus')
await ff.command('fullscreen')
# iterate through all the container windows (or use tree.leaves() for just
# application windows)
for container in workspace:
print(f'On the focused workspace: {container.name}')