Simplify compact_workspace_numbers even more
This commit is contained in:
parent
53f2e6ade5
commit
0c7f9234f3
@ -3,22 +3,13 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
|
||||||
exclude_workspaces = (-1, 10)
|
workspaces = json.loads(
|
||||||
|
subprocess.check_output(["i3-msg", "-t", "get_workspaces"]))
|
||||||
|
workspaces = [ws for ws in workspaces if ws['num'] not in (-1, 10)]
|
||||||
|
|
||||||
def numbered_workspaces():
|
workspaces.sort(key=lambda x: x['num'])
|
||||||
workspaces = json.loads(subprocess.run(["i3-msg", "-t", "get_workspaces"],
|
for num, ws in enumerate(workspaces, 1):
|
||||||
stdout=subprocess.PIPE).stdout)
|
name = ws['name'].split(":")
|
||||||
return {int(ws['num']): ws for ws in workspaces if ws['num'] not in exclude_workspaces}
|
name[0] = str(num)
|
||||||
|
subprocess.run(
|
||||||
workspaces = sorted(numbered_workspaces().keys())
|
["i3", "rename", "workspace", ws['name'], "to", ":".join(name)])
|
||||||
num = 1
|
|
||||||
print(workspaces)
|
|
||||||
while len(workspaces) > 0:
|
|
||||||
ws = numbered_workspaces()[workspaces.pop(0)]
|
|
||||||
if ws['num'] != num:
|
|
||||||
new_name = ws['name'].split(":")
|
|
||||||
new_name[0] = str(num)
|
|
||||||
print("move", ws['num'], '->', num)
|
|
||||||
subprocess.run(["i3-msg", "rename", "workspace",
|
|
||||||
ws['name'], "to", ":".join(new_name)])
|
|
||||||
num += 1
|
|
||||||
|
Loading…
Reference in New Issue
Block a user