| 4 | from .wminterface import WMInterface |
| 5 | |
| 6 | class KDEInterface (WMInterface): |
| 7 | def __init__(self) -> None: |
| 8 | super().__init__() |
| 9 | self.x = 0 |
| 10 | self.y = 0 |
| 11 | |
| 12 | def get_cursor_position(self) -> tuple[int, int]: |
| 13 | script = "kdotool getmouselocation" |
| 14 | mouse_pos = subprocess.check_output(["bash","-c", script]) |
| 15 | string = mouse_pos.decode("utf-8") |
| 16 | match = re.search(r'x:(\d+)\s+y:(\d+)', string) |
| 17 | if match is None: |
| 18 | return 0,0 |
| 19 | x = int(match.group(1)) |
| 20 | y = int(match.group(2)) |
| 21 | pos = self._get_relative_coords(x, y) |
| 22 | return pos |
| 23 | |
| 24 | def get_active_monitor_resolution(self) -> tuple[int, int]: |
| 25 | return 1920, 1000 |
| 26 | |
| 27 | def _get_relative_coords(self, x:int, y:int) -> tuple[int, int]: |
| 28 | return x-self.x,y-self.y |