fix: restore anti-idle in manager.py, fix ENTRYPOINT quoting in Dockerfile
- manager.py: anti_idle_loop sends xdotool Shift to xfreerdp window every 30s while session is active; mousemove fallback if window not found - Dockerfile: restore xdotool package; fix ENTRYPOINT JSON quoting lost in heredoc
This commit is contained in:
@@ -2,7 +2,7 @@ FROM debian:bookworm-slim
|
|||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends python3 xvfb x11vnc freerdp2-x11 novnc websockify ca-certificates fonts-dejavu-core && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y --no-install-recommends python3 xvfb x11vnc freerdp2-x11 novnc websockify xdotool ca-certificates fonts-dejavu-core && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
COPY manager.py /manager.py
|
COPY manager.py /manager.py
|
||||||
|
|||||||
@@ -70,6 +70,35 @@ def _monitor_loop():
|
|||||||
|
|
||||||
|
|
||||||
threading.Thread(target=_monitor_loop, daemon=True).start()
|
threading.Thread(target=_monitor_loop, daemon=True).start()
|
||||||
|
def _anti_idle_loop():
|
||||||
|
"""Send Shift key every 30s while xfreerdp is connected to prevent screen lock."""
|
||||||
|
while True:
|
||||||
|
time.sleep(30)
|
||||||
|
with _lock:
|
||||||
|
active = _should_be_connected and _proc is not None and _proc.poll() is None
|
||||||
|
if not active:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
# Try to send Shift to xfreerdp window
|
||||||
|
result = subprocess.run(
|
||||||
|
["xdotool", "search", "--name", "FreeRDP", "key", "shift"],
|
||||||
|
env={**os.environ, "DISPLAY": DISPLAY},
|
||||||
|
capture_output=True, timeout=5,
|
||||||
|
)
|
||||||
|
if result.returncode != 0:
|
||||||
|
# Fallback: mousemove
|
||||||
|
subprocess.run(
|
||||||
|
["xdotool", "mousemove", "--sync", "960", "540"],
|
||||||
|
env={**os.environ, "DISPLAY": DISPLAY},
|
||||||
|
capture_output=True, timeout=5,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
log.debug("anti_idle error: %s", e)
|
||||||
|
|
||||||
|
|
||||||
|
threading.Thread(target=_anti_idle_loop, daemon=True).start()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Handler(BaseHTTPRequestHandler):
|
class Handler(BaseHTTPRequestHandler):
|
||||||
|
|||||||
Reference in New Issue
Block a user