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 subprocess
|
||||||
import json
|
import json
|
||||||
|
from itertools import groupby
|
||||||
|
|
||||||
workspaces = json.loads(
|
workspaces = json.loads(
|
||||||
subprocess.check_output(["i3-msg", "-t", "get_workspaces"]))
|
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 tens, workspace_group in groupby(workspaces, lambda x: x['num'] // 10):
|
||||||
for num, ws in enumerate(workspaces, 1):
|
workspaces = [ws for ws in workspace_group
|
||||||
name = ws['name'].split(":")
|
if ws['num'] != -1 and ws['num'] % 10 != 0]
|
||||||
name[0] = str(num)
|
|
||||||
subprocess.run(
|
workspaces.sort(key=lambda x: x['num'])
|
||||||
["i3", "rename", "workspace", ws['name'], "to", ":".join(name)])
|
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