From ad231134af785ec4280b50793f99ad4c6c85e33e Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sun, 12 Jan 2025 00:25:06 +0000 Subject: [PATCH] Remove the udev stuff --- microkodi/main.py | 18 +----------------- microkodi/udev.py | 27 --------------------------- pyproject.toml | 3 +-- 3 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 microkodi/udev.py diff --git a/microkodi/main.py b/microkodi/main.py index 28345b7..8880df5 100644 --- a/microkodi/main.py +++ b/microkodi/main.py @@ -14,7 +14,6 @@ from microkodi.jsonrpc import JsonRpcHandler, GlobalMethodHandler from microkodi.ui.bridge import DataBridge from microkodi.config import Config, load_config from microkodi.repository import I -from microkodi.udev import is_display_connected, block_until_display_connected def run_kodi_server(): @@ -96,21 +95,6 @@ if __name__ == "__main__": if config.watch_connector: logger.info("Will be watching display if it's gone") - exit_code = 0 - while True: - exit_code = app.exec() - - if not config.watch_connector: - break - - # Exit if the display is still connected - if is_display_connected(config.card, config.connector): - break - - logger.info("Display is gone. Waiting until it's back") - block_until_display_connected(config.card, config.connector) - logger.info("Display is back. Waiting 500ms...") - time.sleep(0.5) - + exit_code = app.exec() del engine sys.exit(exit_code) \ No newline at end of file diff --git a/microkodi/udev.py b/microkodi/udev.py deleted file mode 100644 index daf3f8b..0000000 --- a/microkodi/udev.py +++ /dev/null @@ -1,27 +0,0 @@ -import logging - -import pyudev - -def is_display_connected(card: str, connector: str) -> bool: - logger = logging.getLogger("udev") - status_file = f"/sys/class/drm/{card}-{connector}/status" - logger.debug("Reading file %s", status_file) - with open(status_file, "r") as f: - result = f.read().strip() - logger.debug("Result: '%s'", result) - return result == "connected" - -def block_until_display_connected(card: str, connector: str): - ctx = pyudev.Context() - monitor = pyudev.Monitor.from_netlink(ctx) - monitor.filter_by("drm") - for device in iter(monitor.poll, None): - if not "DEVNAME" in device: - continue - - if device.get("DEVNAME") != f"/dev/dri/{card}": - continue - - if not is_display_connected(card, connector): - continue - break \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f7eccf3..b23d560 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,7 @@ version = "0.1.0" dependencies = [ "pyside6", "requests", - "yt-dlp", - "pyudev" + "yt-dlp" ] [tools.build]