import i3ipc import sys from itertools import zip_longest, count i3 = i3ipc.Connection() workspaces = (w.name for w in i3.get_workspaces()) for i, workspace in zip(count(1), workspaces): name = workspace.split(":", 1)[-1] i3.command(f"rename workspace '{workspace}' to '{i}:{name}'") print(i, name, file=sys.stderr)