38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
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 start_cancel_listener(self, callback: Callable[[], None]) -> None:
|
|
raise NotImplementedError
|
|
|
|
def inject_text(
|
|
self,
|
|
text: str,
|
|
backend: str,
|
|
*,
|
|
remove_transcription_from_clipboard: bool = False,
|
|
) -> None:
|
|
raise NotImplementedError
|
|
|
|
def run_tray(self, state_getter: Callable[[], str], on_quit: Callable[[], None]) -> None:
|
|
raise NotImplementedError
|
|
|
|
def request_quit(self) -> 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"):
|
|
raise SystemExit(
|
|
"Wayland is not supported yet. Run under X11 (XDG_SESSION_TYPE=x11) to use lel."
|
|
)
|
|
from desktop_x11 import X11Adapter
|
|
|
|
return X11Adapter()
|