summaryrefslogtreecommitdiff
path: root/.i3/scripts/new_workspace.py
blob: cfb73d1f35373ba5c358b312232ee34258cb52fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python

#
# Switch to a new workspace, which gets the first free numbe >= 0
#

import sys
from os.path import realpath, dirname

cwd = realpath(dirname(__file__))
sys.path.insert(1, cwd)

import i3

nums = (w["num"] for w in i3.get_workspaces())
nums = filter(lambda n: n is not None and n >= 0, nums)

for i,n in enumerate(sorted(nums)):
    if i != n:
        i3.workspace(str(i))
        break
else:
    i3.workspace(str(i+1))