60 lines
1.8 KiB
Python
60 lines
1.8 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 stop_hotkey_listener(self) -> None:
|
|
raise NotImplementedError
|
|
|
|
def validate_hotkey(self, hotkey: str) -> None:
|
|
raise NotImplementedError
|
|
|
|
def start_cancel_listener(self, callback: Callable[[], None]) -> None:
|
|
raise NotImplementedError
|
|
|
|
def stop_cancel_listener(self) -> 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],
|
|
*,
|
|
on_open_settings: Callable[[], None] | None = None,
|
|
on_show_help: Callable[[], None] | None = None,
|
|
on_show_about: Callable[[], None] | None = None,
|
|
is_paused_getter: Callable[[], bool] | None = None,
|
|
on_toggle_pause: Callable[[], None] | None = None,
|
|
on_reload_config: Callable[[], None] | None = None,
|
|
on_run_diagnostics: Callable[[], None] | None = None,
|
|
on_open_config: Callable[[], None] | None = 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 aman."
|
|
)
|
|
from desktop_x11 import X11Adapter
|
|
|
|
return X11Adapter()
|