sway: Update compact script to take screens into account
This commit is contained in:
parent
127d16e54f
commit
32ca185cd3
1 changed files with 22 additions and 5 deletions
|
@ -1,11 +1,28 @@
|
|||
import i3ipc
|
||||
import sys
|
||||
from itertools import zip_longest, count
|
||||
from beeprint import pp
|
||||
|
||||
i3 = i3ipc.Connection()
|
||||
outputs = ("DP-2", "HDMI-A-1", "DP-3")
|
||||
|
||||
workspaces = (w.name for w in i3.get_workspaces())
|
||||
for i, workspace in zip(count(1), workspaces):
|
||||
name = workspace.split(":", 1)[-1]
|
||||
i3.command(f"rename workspace '{workspace}' to '{i}:{name}'")
|
||||
print(i, name, file=sys.stderr)
|
||||
|
||||
def workspace_key(workspace):
|
||||
try:
|
||||
output_rank = outputs.index(workspace.output)
|
||||
except ValueError:
|
||||
output_rank = 1000
|
||||
|
||||
return (output_rank, workspace.name)
|
||||
|
||||
|
||||
workspaces = sorted(i3.get_workspaces(), key=workspace_key)
|
||||
number = 0
|
||||
for i, workspace in enumerate(workspaces):
|
||||
number += 1
|
||||
if i > 0 and workspaces[i - 1].output != workspaces[i].output:
|
||||
number += 1
|
||||
|
||||
name = (":" + workspace.name.split(":", 1)[-1]) if ":" in workspace.name else ""
|
||||
i3.command(f"rename workspace '{workspace.name}' to '{number}{name}'")
|
||||
print(number, name, file=sys.stderr)
|
||||
|
|
Loading…
Reference in a new issue