Add desktop adapters and extras

This commit is contained in:
Thales Maciel 2026-02-24 12:59:19 -03:00
parent a83a843e1a
commit fb1d0c07f9
No known key found for this signature in database
GPG key ID: 33112E6833C34679
10 changed files with 383 additions and 276 deletions

28
src/desktop.py Normal file
View file

@ -0,0 +1,28 @@
from __future__ import annotations
import os
from typing import Callable, Protocol
class DesktopAdapter(Protocol):
def start_hotkey_listener(self, hotkey: str, callback: Callable[[], None]) -> None:
raise NotImplementedError
def inject_text(self, text: str, backend: str) -> None:
raise NotImplementedError
def run_tray(self, state_getter: Callable[[], str], on_quit: Callable[[], None]) -> None:
raise NotImplementedError
def get_desktop_adapter() -> DesktopAdapter:
session_type = os.getenv("XDG_SESSION_TYPE", "").lower()
if session_type == "wayland" or os.getenv("WAYLAND_DISPLAY"):
from desktop_wayland import WaylandAdapter
raise SystemExit(
"Wayland is not supported yet. Run under X11 (XDG_SESSION_TYPE=x11) to use lel."
)
from desktop_x11 import X11Adapter
return X11Adapter()