Skip to content

Dismiss screensaver on pointer motion - #8048

Open
kazeshini178 wants to merge 3 commits into
omacom:quattrofrom
kazeshini178:screensaver-dismiss-on-pointer-motion
Open

kazeshini178 wants to merge 3 commits into
omacom:quattrofrom
kazeshini178:screensaver-dismiss-on-pointer-motion

Conversation

@kazeshini178

@kazeshini178 kazeshini178 commented Aug 24, 2026 •

Copy link
Copy Markdown

Addresses part of #7762.

Problem

Only a keypress dismisses the screensaver. Mouse and trackpad input do nothing.

omarchy-screensaver detects input with read -n1 on stdin, which carries the keyboard alone — ttfx never enables terminal mouse reporting, so pointer motion has no path into the process. The other exit condition cannot fire either: screensaver_in_focus only goes false when the focused window's class changes, and the window is fullscreen on every monitor.

This was shipped once and reverted — and the stated cause no longer reproduces

Being upfront about the precedent, because it applies to every proposed fix in #7762:

  • ddf0d1e8 (Exit screensaver when mouse moves or clicks #3723) armed terminal mouse reporting and shipped in v3.2.3
  • d2ea6ad1 reverted it for v3.3.0: "Canceling the screensaver on mouse movement doesn't work with bluetooth mice. Could not get it to stop existing with a Logitech MX4 when connected via bluetooth."

I tested that specific failure. On a Logitech M720 Triathlon over Bluetooth — BlueZ uhid transport, bus 0005 (BUS_BLUETOOTH), lsusb showing no Unifying receiver, and Hyprland listing it as a second pointer alongside the internal trackpad — with reporting armed:

Input SGR bytes delivered
Trackpad motion (control) 3876, and 4488 on a repeat
Bluetooth mouse motion 3559
Bluetooth mouse click 177
Bluetooth mouse scroll 876

A Bluetooth mouse reaches the terminal at essentially the same rate as the built-in trackpad. Different mouse model and nine months of libinput/Wayland/foot changes since d2ea6ad1, so this does not prove the original report was wrong — but the reason it was reverted does not hold on current Omarchy, and that precedent is otherwise hanging over this whole area unexamined.

Fix

Enable any-event mouse tracking (?1003h) with SGR coordinates (?1006h) so the terminal delivers pointer motion on stdin, where the existing read loop already dismisses. Disabled again on teardown.

Two details worth calling out:

Arming waits for launch to finish. omarchy-launch-screensaver focuses each monitor in turn, which warps the pointer on multi-monitor setups. A warp landing after reporting is armed reads as user input and dismisses the screensaver the instant it appears. Sampling the pointer every 100ms across three runs on a two-monitor session:

  0 ms  win=0
100 ms  win=0  LAUNCHER WARP -> 479, 613     (focusing the second monitor)
200 ms  win=1  LAUNCHER WARP -> -960, 553    (restoring focus)
300 ms  win=2                                 both screensavers up

The first version armed after a fixed one second, which covered these 100–400ms warps. But wait_for_screensaver_window allows up to 5s per monitor, so a slow terminal on a later monitor could map after arming. Reviewers on #7528 and #7780 flagged the same race there. Arming now waits until every monitor has a mapped org.omarchy.screensaver window, then waits 0.5s for the launcher's last warp: the focus restore that runs straight after the final window maps. The wait is capped at 5s per monitor, matching the launcher's own deadline, so a terminal that never maps can't leave the mouse dead. The failure mode is still mild if it is ever wrong: the screensaver closes immediately and idle re-triggers. The warp measurements above were taken with the fixed delay. The launch-complete wait has been checked by script syntax and against sample hyprctl output, but not yet in a live multi-monitor session.

Arming runs in the background. In the foreground it blocks before the read loop, leaving the keyboard dead until it arms — worse than current behaviour.

It also fixes the lock-during-activity defect

Worth separating, because #7762 contains two problems and this addresses both.

The genuine regression identified in that thread is that handleActiveSignal() is edge-triggered off IdleMonitor.onIsIdleChanged: while the user keeps moving, the monitor never re-idles, no further edge arrives, lockTimer is never stopped, and the session locks on the original deadline however active the user has been.

This patch fixes that through the sanctioned path — pointer input closes the window, so closewindow → handleScreensaverWindowClosed → cancelIdleCycle → lockTimer.stop(). Note the guard-narrowing suggested in the issue does not fix it.

Verification

Two-monitor Hyprland session with one display at negative X, so focusing it warps the pointer ~1400px. Both windows survived 2.8s past arming untouched, then a single trackpad nudge closed both within 200ms.

Input coverage, measured by logging bytes arriving with reporting armed:

Input Dismisses
Pointer motion yes
Left click yes
Two-finger scroll yes
Pinch to zoom yes
Bluetooth mouse (motion / click / scroll) yes
Three-finger swipe no
Volume / brightness keys no

The two gaps are inherent to the terminal layer: Wayland three-finger gestures use the pointer-gestures protocol, which foot does not implement, and media keys never arrive as stdin bytes. Neither is a regression — today nothing but a keypress dismisses at all.

All four supported terminals

Dismissal depends on the terminal translating pointer input into SGR reports on the pty, which is per-terminal behaviour, so I measured each one using the flags omarchy-launch-screensaver passes it. Bytes delivered with reporting armed, internal trackpad and the Bluetooth M720:

Terminal Version Trackpad Bluetooth mouse
foot 1.27.0 552 583
ghostty 1.3.1 270 / 324 416 / 696
alacritty 0.17.0 330 465
kitty 0.48.2 526 792

Every terminal reports both devices (ghostty run twice, consistent). So the mechanism is not foot-specific, and the Bluetooth result is not terminal-specific either.

test/shell.d/screensaver-mouse-arming-test.sh runs the real script against stubbed hyprctl, ttfx and pkill, with the keyboard on a FIFO. It checks four things:

  • reporting waits while a monitor still lacks its screensaver, then arms once all are mapped;
  • the 5s cap arms when one never maps;
  • dismissal turns reporting back off and closes the windows;
  • a keypress before arming dismisses and stops the arming job.

The last case found an orphaned arming job that kept polling Hyprland after exit, now fixed. The test fails against the original fixed-delay version and against the script without the fix. It passes 3/3 repeat runs, and ./test/cli passes.

./test/all (before these follow-ups): 186/190. The four failures are pre-existing in my environment and unrelated to a shell script in bin/ — config-test.sh and unowned-system-paths-test.sh need an omarchy-pkgs checkout, snapper-test.sh hits a permission error, and runtime-smoke-test.sh fails its per-screen IPC assertion (saw 3 for 2 screen(s)) whenever two displays are attached, on a clean tree as well.

Limitations, stated plainly

Tested on Omarchy 4.0.0-1, ttfx 0.3.1, Hyprland with 1 and 2 monitors, internal trackpad and a Bluetooth Logitech M720, across foot 1.27.0, ghostty 1.3.1, alacritty 0.17.0 and kitty 0.48.2.

Copilot AI balanced review requested due to automatic review settings August 24, 2026 14:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The screensaver detects input with `read -n1` on stdin, which carries the
keyboard alone. ttfx never enables terminal mouse reporting, so trackpad and
mouse motion have no path into the process, and the other exit condition
(losing focus) cannot fire because the window is fullscreen on every monitor.

Enable any-event mouse tracking so the terminal delivers motion on stdin and
the existing read loop exits on pointer input too.

This re-arms the mechanism ddf0d1e shipped in v3.2.3, which d2ea6ad then
reverted for v3.3.0 because it did not work with Bluetooth mice ("Could not
get it to stop existing with a Logitech MX4 when connected via bluetooth").
That cause does not reproduce here. On a Logitech M720 Triathlon connected
over Bluetooth (BlueZ uhid transport, bus 0005, no Unifying receiver present),
motion delivered 3559 bytes of SGR reports, a click 177 and the scroll wheel
876, against an internal-trackpad control of 3876 and 4488 bytes in the same
session.

Arm it a second late. omarchy-launch-screensaver focuses each monitor in turn,
which warps the pointer when there is more than one, and a warp that lands
after arming reads as user input and dismisses the screensaver on sight.
Sampling the pointer every 100ms across three runs on a two-monitor session,
the launcher's last warp arrives 100-400ms after launch; one second leaves a
margin.

Arming runs in the background so the read loop starts immediately, keeping the
keyboard responsive from the first frame rather than ignoring it for a second.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Replace the fixed 1s delay with a bounded wait for a mapped screensaver
on every monitor, then a 0.5s settle for the launcher's focus-restore
warp. Capped at 5s per monitor, matching the launcher's own deadline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds mouse-motion dismissal to the screensaver.

The PR appears safe to merge; the previous test-coverage concern is addressed.

Summary

The PR enables pointer input to dismiss the screensaver. Mouse reporting starts in the background after the launch wait and stops during teardown.

  • The latest changes cancel pending arming when the screensaver exits.
  • New shell tests address the previous request for delayed-arming, timeout, and early-keyboard coverage.
  • No new actionable issues were found. Tests were inspected but not run.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Start[Start screensaver] --> Arm[Wait for windows in background]
  Start --> Read[Read keyboard input immediately]
  Arm --> Settle[Wait briefly]
  Settle --> Mouse[Enable mouse reporting]
  Mouse --> Read
  Read --> Exit[Input dismisses screensaver]
  Exit --> Cancel[Stop pending arming]
  Cancel --> Reset[Disable mouse reporting and close windows]
Loading

Reviews (2) · Last reviewed commit: "Test screensaver mouse arming; stop armi..." · Reviewed by Greptile

Comment thread bin/omarchy-screensaver Resolved
Cover waiting for every monitor, the 5s-per-monitor cap, teardown
disarming, and keyboard dismissal before arming. The last exposed an
orphaned arming job that kept polling Hyprland after exit; kill it in
exit_screensaver.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants