refactor: convert hotkey module to package with evdev backend
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
"""Hotkey-Listener — plattformspezifische Backends hinter gemeinsamem Interface."""
|
||||
|
||||
import sys
|
||||
from typing import Callable, Coroutine, Protocol, runtime_checkable
|
||||
|
||||
AsyncCallback = Callable[[], Coroutine]
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class HotkeyListener(Protocol):
|
||||
on_press: AsyncCallback | None
|
||||
on_release: AsyncCallback | None
|
||||
|
||||
async def listen(self) -> None: ...
|
||||
|
||||
|
||||
def create_listener(key_name: str = "KEY_F12") -> HotkeyListener:
|
||||
"""Erstellt den plattformspezifischen HotkeyListener."""
|
||||
if sys.platform == "linux":
|
||||
from whisper_local.hotkey._evdev import EvdevHotkeyListener
|
||||
return EvdevHotkeyListener(key_name)
|
||||
else:
|
||||
from whisper_local.hotkey._pynput import PynputHotkeyListener
|
||||
return PynputHotkeyListener(key_name)
|
||||
Reference in New Issue
Block a user