dotfiles/config/i3/next-free.py
2020-03-04 13:27:36 +01:00

15 lines
393 B
Python

import i3ipc
import sys
from itertools import zip_longest, count
i3 = i3ipc.Connection()
workspaces = sorted(int(w.name.split(":")[0]) for w in i3.get_workspaces())
for i, workspace in zip_longest(count(1), workspaces):
print(i, workspace, file=sys.stderr)
if i != workspace:
print(i)
break
else:
print("no free workspace found", file=sys.stderr)
sys.exit(1)