Fix Gdk version loading
This commit is contained in:
parent
fb1d0c07f9
commit
42cf10cce3
1 changed files with 8 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ import gi
|
||||||
from Xlib import X, XK, display
|
from Xlib import X, XK, display
|
||||||
from Xlib.ext import xtest
|
from Xlib.ext import xtest
|
||||||
|
|
||||||
|
gi.require_version("Gdk", "3.0")
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
try:
|
try:
|
||||||
gi.require_version("AppIndicator3", "0.1")
|
gi.require_version("AppIndicator3", "0.1")
|
||||||
|
|
@ -59,6 +60,10 @@ class X11Adapter:
|
||||||
self.status_icon.set_visible(True)
|
self.status_icon.set_visible(True)
|
||||||
self.status_icon.connect("popup-menu", self._on_tray_menu)
|
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:
|
def start_hotkey_listener(self, hotkey: str, callback: Callable[[], None]) -> None:
|
||||||
thread = threading.Thread(target=self._listen, args=(hotkey, callback), daemon=True)
|
thread = threading.Thread(target=self._listen, args=(hotkey, callback), daemon=True)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
@ -163,13 +168,13 @@ class X11Adapter:
|
||||||
else:
|
else:
|
||||||
self._send_combo(dpy, [keysym], already_keysym=True)
|
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] = []
|
keycodes: list[int] = []
|
||||||
for key in keys:
|
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:
|
if keysym == 0:
|
||||||
continue
|
continue
|
||||||
keycode = dpy.keysym_to_keycode(keysym)
|
keycode = dpy.keysym_to_keycode(int(keysym))
|
||||||
if keycode == 0:
|
if keycode == 0:
|
||||||
continue
|
continue
|
||||||
keycodes.append(keycode)
|
keycodes.append(keycode)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue