diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-17 15:02:12 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-17 15:02:12 +1000 |
| commit | b22ab08a3715f286c086321e843121b4465f1488 (patch) | |
| tree | a4c8a1ce0da572a43372205090edef606fecbc48 | |
| parent | [CI] chore: update flake (diff) | |
| download | caelestia-cli-b22ab08a3715f286c086321e843121b4465f1488.tar.gz caelestia-cli-b22ab08a3715f286c086321e843121b4465f1488.tar.bz2 caelestia-cli-b22ab08a3715f286c086321e843121b4465f1488.zip | |
pip: use batch request
| -rw-r--r-- | src/caelestia/subcommands/pip.py | 6 | ||||
| -rw-r--r-- | src/caelestia/utils/hypr.py | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/caelestia/subcommands/pip.py b/src/caelestia/subcommands/pip.py index 4ee50b4..6f4727d 100644 --- a/src/caelestia/subcommands/pip.py +++ b/src/caelestia/subcommands/pip.py @@ -29,8 +29,10 @@ class Command: off = min(mon["width"], mon["height"]) * 0.03 move_to = f"{int(mon['x']) + int(mon['width'] - off - width * scale_factor)} {int(mon['y']) + int(mon['height'] - off - height * scale_factor)}" - hypr.dispatch("resizewindowpixel", "exact", f"{scaled_win_size},address:{address}") - hypr.dispatch("movewindowpixel", "exact", f"{move_to},address:{address}") + hypr.batch( + f"dispatch resizewindowpixel exact {scaled_win_size},address:{address}", + f"dispatch movewindowpixel exact {move_to},address:{address}", + ) def daemon(self) -> None: with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock: diff --git a/src/caelestia/utils/hypr.py b/src/caelestia/utils/hypr.py index f89cd98..81bc123 100644 --- a/src/caelestia/utils/hypr.py +++ b/src/caelestia/utils/hypr.py @@ -27,3 +27,9 @@ def message(msg: str, json: bool = True) -> str | dict[str, any]: def dispatch(dispatcher: str, *args: list[any]) -> bool: return message(f"dispatch {dispatcher} {' '.join(map(str, args))}".rstrip(), json=False) == "ok" + + +def batch(*msgs: list[str], json: bool = False) -> str | dict[str, any]: + if json: + msgs = (f"j/{m.strip()}" for m in msgs) + return message(f"[[BATCH]]{';'.join(msgs)}", json=False) |