Fix Gdk version loading

This commit is contained in:
Thales Maciel 2026-02-24 13:01:22 -03:00
parent fb1d0c07f9
commit 42cf10cce3
No known key found for this signature in database
GPG key ID: 33112E6833C34679

View file

@ -10,6 +10,7 @@ import gi
from Xlib import X, XK, display
from Xlib.ext import xtest
gi.require_version("Gdk", "3.0")
gi.require_version("Gtk", "3.0")
try:
gi.require_version("AppIndicator3", "0.1")
@ -59,6 +60,10 @@ class X11Adapter:
self.status_icon.set_visible(True)
self.status_icon.connect("popup-menu", self._on_tray_menu)
def _on_tray_menu(self, _icon, _button, _time):
if self.menu:
self.menu.popup(None, None, None, None, 0, _time)
def start_hotkey_listener(self, hotkey: str, callback: Callable[[], None]) -> None:
thread = threading.Thread(target=self._listen, args=(hotkey, callback), daemon=True)
thread.start()
@ -163,13 +168,13 @@ class X11Adapter:
else:
self._send_combo(dpy, [keysym], already_keysym=True)
def _send_combo(self, dpy: display.Display, keys: Iterable[str], already_keysym: bool = False) -> None:
def _send_combo(self, dpy: display.Display, keys: Iterable[str | int], already_keysym: bool = False) -> None:
keycodes: list[int] = []
for key in keys:
keysym = key if already_keysym else XK.string_to_keysym(key)
keysym = key if already_keysym else XK.string_to_keysym(str(key))
if keysym == 0:
continue
keycode = dpy.keysym_to_keycode(keysym)
keycode = dpy.keysym_to_keycode(int(keysym))
if keycode == 0:
continue
keycodes.append(keycode)