| 3 | from .wminterface import WMInterface |
| 4 | |
| 5 | class HyprlandInterface(WMInterface): |
| 6 | def __init__(self) -> None: |
| 7 | super().__init__() |
| 8 | self.x = 0 |
| 9 | self.y = 0 |
| 10 | |
| 11 | def get_cursor_position(self) -> tuple[int, int]: |
| 12 | mouse_pos = subprocess.check_output(["hyprctl", "cursorpos"]) |
| 13 | x, y = mouse_pos.decode("utf-8").split(", ") |
| 14 | x = int(x) |
| 15 | y = int(y) |
| 16 | pos = self._get_relative_coords(x, y) |
| 17 | return pos |
| 18 | def get_active_monitor_resolution(self) -> tuple[int, int]: |
| 19 | monitors = subprocess.check_output(["hyprctl", "monitors", "-j"]) |
| 20 | monitors = json.loads(monitors.decode("utf-8")) |
| 21 | for monitor in monitors: |
| 22 | if monitor["focused"]: |
| 23 | self.x = monitor["x"] |
| 24 | self.y = monitor["y"] |
| 25 | print(self.x, self.y) |
| 26 | return monitor["width"], monitor["height"] |
| 27 | return 1920, 1080 |
| 28 | |
| 29 | def _get_relative_coords(self, x:int, y:int) -> tuple[int, int]: |
| 30 | return x-self.x,y-self.y |