Skip to content

Wait on focus events in the screensaver instead of polling every second - #15206

Closed
dhh wants to merge 1 commit into
quattrofrom
screensaver-battery
Closed

dhh wants to merge 1 commit into
quattrofrom
screensaver-battery

Conversation

@dhh

@dhh dhh commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What changed

bin/omarchy-screensaver spawned pgrep, hyprctl and jq every second per monitor to notice focus leaving. It now:

  • follows Hyprland's event stream (.socket2.sock), opened before anything can move focus, and confirms a focus change a second later (the launcher passes focus through each monitor's window while it opens them);
  • ends when that stream does, rather than staying up unwatched;
  • runs one random effect after another, starting the next only after the previous one plays to the end. A failed effect is retried after a pause; an effect ended by a signal ends the loop, so a lock's stop-and-wait can't race a replacement.

Any key still ends it. The frame rate stays at 120.

The manual no longer says mouse movement exits the screensaver; it never did (ttfx doesn't enable mouse reporting).

Earlier versions of this PR also skipped the screensaver on battery. That part is removed: the screensaver runs on laptops as before.

Measured

Screensaver process wakeups: 61 per 15s on quattro, 0 with this change.

Tests

New test/shell.d/screensaver-test.sh covers focus leaving, the event stream ending, a key, effect sequencing, failed-effect retry and a lock-style stop, all mutation-checked. idle-test.sh and ./test/cli pass.

Human check

Multiple monitors: start the screensaver, then move focus or press a key, and confirm every monitor's instance closes.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The current changes appear safe to merge.

Summary

This diff replaces repeated screensaver polling with a blocking key read and Hyprland focus events.

  • The screensaver listens for focus changes instead of polling every second.

No new actionable issues were found. The current diff does not include the battery changes described in the PR.

Previous acknowledgments:

  • dhh left keyboard brightness restoration unchanged because it predates this PR.
  • dhh accepted ending the idle cycle when the idle monitor already reports activity, because blanking then could leave no activity change to wake the displays. That battery path is not present in the current diff.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Start screensaver] --> B[Open Hyprland event stream]
  B --> C[Wait for terminal resize]
  C --> D[Play effects in background]
  C --> E[Watch focus in background]
  C --> F[Wait for a key]
  E --> G{Another window stays focused?}
  G -->|Yes| H[Exit screensaver]
  E -->|Event stream closes| H
  F --> H
  H --> I[Stop workers and effects]
  I --> J[Restore cursor and close windows]
Loading

Reviews (12) · Last reviewed commit: "Wait on focus events in the screensaver ..." · Reviewed by Greptile

Comment thread bin/omarchy-screensaver Resolved
Comment thread test/shell.d/screensaver-test.sh Resolved
Comment thread test/shell.d/screensaver-test.sh Resolved
@dhh dhh changed the title Lock instead of running the screensaver on battery, and stop its polling Blank the displays instead of running the screensaver on battery, and stop its polling Oct 12, 2026
Comment thread shell/plugins/services/idle/Service.qml Resolved
Comment thread shell/plugins/services/idle/Service.qml Resolved
Comment thread shell/plugins/services/idle/Service.qml Resolved
Comment thread shell/plugins/services/idle/Service.qml Resolved
Comment thread shell/plugins/services/idle/Service.qml Resolved
Comment thread shell/plugins/services/idle/Service.qml Resolved
Comment thread shell/plugins/services/idle/Service.qml Resolved
The screensaver spawned pgrep, hyprctl and jq every second per monitor to
notice focus leaving. It now follows Hyprland's event stream, ends when that
stream does, and runs one effect after another, retrying a failed one after a
pause and stopping on a signal so a lock's stop can't race a replacement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh
dhh force-pushed the screensaver-battery branch from d4b123d to 739b92f Compare October 13, 2026 12:21
@dhh dhh changed the title Blank the displays instead of running the screensaver on battery, and stop its polling Wait on focus events in the screensaver instead of polling every second Oct 13, 2026
@dhh

dhh commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Closing per DHH: keep the screensaver as it is.

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