Skip to content

Add afk or not-afk status key/value to aw-watcher-window - #82

Open
guillaumezin wants to merge 3 commits into
2e3s:mainfrom
guillaumezin:main
Open

guillaumezin wants to merge 3 commits into
2e3s:mainfrom
guillaumezin:main

Conversation

@guillaumezin

Copy link
Copy Markdown

This is really helpful to watch/filter buckets data with Grafana

run_iteration failures

run_first_supported's loop caught every error from run_iteration
(including timeouts) and just logged it, then kept looping forever on
the same broken state. In particular, once a Wayland idle watcher's
event queue socket dies (e.g. "Broken pipe" after the KWin compositor
restarts, crashes, or a suspend/resume cycle invalidates the
connection), there is no reconnection logic anywhere — every
subsequent iteration fails identically, indefinitely, without the
process ever exiting or self-healing.

Since main.rs races the idle and active-window watcher tasks with
tokio::select! and exits the whole process as soon as either task
completes, we can use that as the recovery mechanism: after too many
consecutive failures, give up on the current watcher instance and
return, which ends the process. An external supervisor (systemd,
launch script) is expected to restart it, establishing a fresh
connection to the compositor/X server from scratch.

Changes:
- Track consecutive_failures across loop iterations, reset to 0 on
  success.
- After MAX_CONSECUTIVE_FAILURES (10, i.e. ~50s at the default 5s
  idle poll interval) consecutive errors or timeouts, log a final
  message and return, ending run_first_supported's loop.

Applies uniformly to both WatcherType::Idle and
WatcherType::ActiveWindow since they share this loop.

This complements (does not replace) the staleness-based afk fallback
in report_client.rs: that fallback keeps status reporting safe while
the watcher is stuck and during the brief restart window, while this
change actually restores idle detection instead of leaving it
permanently stuck after a broken connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant