diff --git a/hid_devices.py b/hid_devices.py index 63948dd..f1b4945 100644 --- a/hid_devices.py +++ b/hid_devices.py @@ -10,7 +10,7 @@ from typing import Awaitable, Callable, Literal, Optional, TypedDict, cast import evdev -from watchgod import awatch, AllWatcher +from watchfiles import awatch from a1314_message_filter import A1314MessageFilter from bluetooth_devices import BluetoothDeviceRegistry @@ -165,11 +165,6 @@ def __del__(self) -> None: print("HID Device ",self.device_id," removed") -class DeviceDirWatcher(AllWatcher): - def should_watch_dir(self, entry: os.DirEntry[str]) -> bool: - return entry.path.count('/') == 3 - - class HIDDeviceRegistry: def __init__(self, loop: asyncio.AbstractEventLoop): self.loop = loop @@ -198,7 +193,7 @@ async def send_message_to_devices(self, msg: bytes) -> None: await device.send_message(msg) async def __watch_device_changes(self) -> None: - async for changes in awatch('/dev/input', watcher_cls=DeviceDirWatcher): + async for changes in awatch("/dev/input/", recursive=False): self.__scan_devices() if self.on_devices_changed_handler is not None: await self.on_devices_changed_handler() diff --git a/requirements.txt b/requirements.txt index fb0bed6..a82a619 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,4 @@ hid-tools!=0.4 mypy==1.5.1 PyGObject pyudev -watchgod +watchfiles