allow batch commands

This commit is contained in:
fdev31 2023-04-27 23:24:03 +02:00
parent 6207a5616f
commit f7307f3ef2
2 changed files with 13 additions and 4 deletions

View file

@ -31,6 +31,11 @@ async def hyprctl(command):
if DEBUG: if DEBUG:
print(">>>", command) print(">>>", command)
ctl_reader, ctl_writer = await asyncio.open_unix_connection(HYPRCTL) ctl_reader, ctl_writer = await asyncio.open_unix_connection(HYPRCTL)
if isinstance(command, list):
ctl_writer.write(
f"[[BATCH]] {' ; '.join('dispatch ' + c for c in command)}".encode()
)
else:
ctl_writer.write(f"/dispatch {command}".encode()) ctl_writer.write(f"/dispatch {command}".encode())
await ctl_writer.drain() await ctl_writer.drain()
resp = await ctl_reader.read(100) resp = await ctl_reader.read(100)

View file

@ -17,12 +17,16 @@ class Extension(Plugin):
for mon in await hyprctlJSON("monitors") for mon in await hyprctlJSON("monitors")
if mon["name"] != monitor_id if mon["name"] != monitor_id
) )
workspaces = [w["id"] for w in await hyprctlJSON("workspaces") if w["id"] > 0]
for n in self.workspace_list: batch: list[str] = []
for n in workspaces:
if n in busy_workspaces or n == workspace_id: if n in busy_workspaces or n == workspace_id:
continue continue
await hyprctl(f"moveworkspacetomonitor {n} {monitor_id}") batch.append(f"moveworkspacetomonitor {n} {monitor_id}")
await hyprctl(f"workspace {workspace_id}") batch.append(f"workspace {workspace_id}")
await hyprctl(batch)
async def run_change_workspace(self, direction: str): async def run_change_workspace(self, direction: str):
increment = int(direction) increment = int(direction)