Remove the udev stuff

This commit is contained in:
PapaTutuWawa 2025-01-12 00:25:06 +00:00
parent 03f143cdcb
commit ad231134af
3 changed files with 2 additions and 46 deletions

View File

@ -14,7 +14,6 @@ from microkodi.jsonrpc import JsonRpcHandler, GlobalMethodHandler
from microkodi.ui.bridge import DataBridge from microkodi.ui.bridge import DataBridge
from microkodi.config import Config, load_config from microkodi.config import Config, load_config
from microkodi.repository import I from microkodi.repository import I
from microkodi.udev import is_display_connected, block_until_display_connected
def run_kodi_server(): def run_kodi_server():
@ -96,21 +95,6 @@ if __name__ == "__main__":
if config.watch_connector: if config.watch_connector:
logger.info("Will be watching display if it's gone") logger.info("Will be watching display if it's gone")
exit_code = 0
while True:
exit_code = app.exec() 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)
del engine del engine
sys.exit(exit_code) sys.exit(exit_code)

View File

@ -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

View File

@ -4,8 +4,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"pyside6", "pyside6",
"requests", "requests",
"yt-dlp", "yt-dlp"
"pyudev"
] ]
[tools.build] [tools.build]