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:
@@ -71,8 +71,9 @@ def _monitor_loop():
|
||||
|
||||
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."""
|
||||
"""Move mouse inside xfreerdp window every 30s — works on any remote OS."""
|
||||
env = {**os.environ, "DISPLAY": DISPLAY}
|
||||
toggle = False
|
||||
while True:
|
||||
time.sleep(30)
|
||||
with _lock:
|
||||
@@ -86,17 +87,16 @@ def _anti_idle_loop():
|
||||
)
|
||||
win_id = r.stdout.decode().strip().splitlines()[0] if r.stdout.strip() else ""
|
||||
if win_id:
|
||||
# Чередуем позицию — tiny mouse jiggle внутри окна xfreerdp
|
||||
x, y = (960, 540) if toggle else (961, 541)
|
||||
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,
|
||||
)
|
||||
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:
|
||||
subprocess.run(
|
||||
["xdotool", "mousemove", "--sync", "960", "540"],
|
||||
env=env, capture_output=True, timeout=5,
|
||||
)
|
||||
log.debug("anti_idle mousemove fallback")
|
||||
log.debug("anti_idle: xfreerdp window not found")
|
||||
except Exception as e:
|
||||
log.debug("anti_idle error: %s", e)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user