Remove the udev stuff
This commit is contained in:
parent
03f143cdcb
commit
ad231134af
@ -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)
|
@ -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
|
@ -4,8 +4,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"pyside6",
|
||||
"requests",
|
||||
"yt-dlp",
|
||||
"pyudev"
|
||||
"yt-dlp"
|
||||
]
|
||||
|
||||
[tools.build]
|
||||
|
Loading…
Reference in New Issue
Block a user