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

Class GnomeInterface

src/wminterfaces/gnomeinterface.py:6–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4from .wminterface import WMInterface
5
6class GnomeInterface (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 = """
14UUID="nyarchpet@nyarchlinux.moe"
15DBUS_ID=$(echo $UUID | sed 's/[^a-zA-Z0-9_]/_/g')
16
17gdbus call --session --dest org.gnome.Shell \
18 --object-path "/org/gnome/Shell/Extensions/${DBUS_ID}" \
19 --method "org.gnome.Shell.Extensions.${DBUS_ID}.GetPosition"
20 """
21 mouse_pos = subprocess.check_output(["bash","-c", script])
22 string = mouse_pos.decode("utf-8")
23 match = re.search(r".*x': <(\d+)>, 'y': <(\d+)>", string)
24 if match is None:
25 return 0,0
26 x = int(match.group(1))
27 y = int(match.group(2))
28 pos = self._get_relative_coords(x, y)
29 return pos
30
31 def get_active_monitor_resolution(self) -> tuple[int, int]:
32 return 1920, 1000
33
34 def _get_relative_coords(self, x:int, y:int) -> tuple[int, int]:
35 return x-self.x,y-self.y

Callers 1

get_wm_interfaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected