dotfiles/config/i3/next-free.py

16 lines
393 B
Python
Raw Normal View History

2020-03-04 12:27:36 +00:00
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)