Add support for multiple monitors (via 10s place) in compact_workspace_numbers
This commit is contained in:
parent
3bafc0b20b
commit
b03b0f8d85
@ -2,14 +2,18 @@
|
||||
|
||||
import subprocess
|
||||
import json
|
||||
from itertools import groupby
|
||||
|
||||
workspaces = json.loads(
|
||||
subprocess.check_output(["i3-msg", "-t", "get_workspaces"]))
|
||||
workspaces = [ws for ws in workspaces if ws['num'] not in (-1, 10)]
|
||||
|
||||
workspaces.sort(key=lambda x: x['num'])
|
||||
for num, ws in enumerate(workspaces, 1):
|
||||
name = ws['name'].split(":")
|
||||
name[0] = str(num)
|
||||
subprocess.run(
|
||||
["i3", "rename", "workspace", ws['name'], "to", ":".join(name)])
|
||||
for tens, workspace_group in groupby(workspaces, lambda x: x['num'] // 10):
|
||||
workspaces = [ws for ws in workspace_group
|
||||
if ws['num'] != -1 and ws['num'] % 10 != 0]
|
||||
|
||||
workspaces.sort(key=lambda x: x['num'])
|
||||
for num, ws in enumerate(workspaces, 1):
|
||||
name = ws['name'].split(":")
|
||||
name[0] = str(tens * 10 + num)
|
||||
subprocess.run(
|
||||
["i3", "rename", "workspace", ws['name'], "to", ":".join(name)])
|
||||
|
Loading…
Reference in New Issue
Block a user