Add desktop adapters and extras
This commit is contained in:
parent
a83a843e1a
commit
fb1d0c07f9
10 changed files with 383 additions and 276 deletions
28
src/desktop.py
Normal file
28
src/desktop.py
Normal 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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue