fix: anti-idle uses mouse jiggle instead of Shift key

Mouse movement works universally on any remote OS (Windows, Ubuntu,
RED OS, Astra). Alternates between (960,540) and (961,541) every 30s
inside xfreerdp window via xdotool mousemove --window.
This commit is contained in:
2026-05-01 16:05:04 +00:00
parent 34972af7c0
commit ccf7401f71
+8 -8
View File
@@ -71,8 +71,9 @@ def _monitor_loop():
threading.Thread(target=_monitor_loop, daemon=True).start() threading.Thread(target=_monitor_loop, daemon=True).start()
def _anti_idle_loop(): def _anti_idle_loop():
"""Send Shift key every 30s while xfreerdp is connected to prevent screen lock.""" """Move mouse inside xfreerdp window every 30s — works on any remote OS."""
env = {**os.environ, "DISPLAY": DISPLAY} env = {**os.environ, "DISPLAY": DISPLAY}
toggle = False
while True: while True:
time.sleep(30) time.sleep(30)
with _lock: with _lock:
@@ -86,17 +87,16 @@ def _anti_idle_loop():
) )
win_id = r.stdout.decode().strip().splitlines()[0] if r.stdout.strip() else "" win_id = r.stdout.decode().strip().splitlines()[0] if r.stdout.strip() else ""
if win_id: if win_id:
# Чередуем позицию — tiny mouse jiggle внутри окна xfreerdp
x, y = (960, 540) if toggle else (961, 541)
subprocess.run( subprocess.run(
["xdotool", "key", "--window", win_id, "--clearmodifiers", "shift"], ["xdotool", "mousemove", "--window", win_id, str(x), str(y)],
env=env, capture_output=True, timeout=5, env=env, capture_output=True, timeout=5,
) )
log.debug("anti_idle shift sent window=%s", win_id) toggle = not toggle
log.debug("anti_idle mousemove window=%s pos=%s,%s", win_id, x, y)
else: else:
subprocess.run( log.debug("anti_idle: xfreerdp window not found")
["xdotool", "mousemove", "--sync", "960", "540"],
env=env, capture_output=True, timeout=5,
)
log.debug("anti_idle mousemove fallback")
except Exception as e: except Exception as e:
log.debug("anti_idle error: %s", e) log.debug("anti_idle error: %s", e)