MCPcopy Create free account
hub / github.com/NyarchLinux/DesktopPuppet / HyprlandInterface

Class HyprlandInterface

src/wminterfaces/hyprlandinterface.py:5–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3from .wminterface import WMInterface
4
5class 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

Callers 1

get_wm_interfaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected