1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#!/usr/bin/env python3
from argparse import ArgumentParser
import i3ipc
i3 = i3ipc.Connection()
def focused_windows():
tree = i3.get_tree()
workspaces = tree.workspaces()
for workspace in workspaces:
container = workspace
while container:
if not hasattr(container, 'focus') or not container.focus:
break
container_id = container.focus[0]
container = container.find_by_id(container_id)
if container:
coname = container.name
wsname = workspace.name
print('WS', wsname + ':', coname)
if __name__ == '__main__':
parser = ArgumentParser(description='Print the names of the focused window of each workspace.')
parser.parse_args()
focused_windows()
|