Skip to content

Keep screensavers open while the launcher moves focus between monitors - #15243

Open
juan-LARRAYA wants to merge 4 commits into
omacom:quattrofrom
juan-LARRAYA:fix/issue-9713
Open

juan-LARRAYA wants to merge 4 commits into
omacom:quattrofrom
juan-LARRAYA:fix/issue-9713

Conversation

@juan-LARRAYA

@juan-LARRAYA juan-LARRAYA commented Oct 13, 2026 •

Copy link
Copy Markdown

Cause

omarchy-launch-screensaver focuses each monitor in turn and waits for its screensaver to map. Until it does, a foreign toplevel is the active window. A screensaver already running on an earlier monitor polls hyprctl activewindow once a second, reads that as the user clicking away and calls exit_screensaver, whose pkill -f '[o]rg.omarchy.screensaver' also kills the terminal still starting on the next monitor. That monitor never emits openwindow, so the launcher waits out its 5 s deadline (the capture in the issue). A slower terminal widens the gap, and raising the deadline would not help because the window it waits for is already dead.

#7102 (latch) does not cover this: the earlier instance has already latched focus, so losing it still exits (see the comment there). #13475 only ignores missing focus for a fixed 5 s per instance and targets the panel case.

Change

The launcher writes its pid to $XDG_RUNTIME_DIR/omarchy-screensaver-launching while it steps through monitors and removes it on exit, including INT/TERM (trap). omarchy-screensaver skips the focus check only while that pid is alive, so a marker left by a killed launcher is ignored. Keypress dismissal and the focus check after launch are unchanged.

Testing

  • New test/shell.d/screensaver-launching-test.sh runs the real launcher and watchdog against stubs (hyprctl, socat, pgrep, ttfx, pkill): the launcher sets the marker while spawning and clears it on completion and on SIGTERM; the watchdog survives a foreign active window while the launcher is alive, but not with a dead launcher's marker or no marker. Fails on the base and on the previous revision of this PR (interrupt case), passes now.
  • test/shell.d/screensaver-workspace-test.sh and system-lock-test.sh pass.
  • Not tested on a live multi-monitor Hyprland session (would require opening windows/moving focus).

Fixes #9713

🤖 Generated with Claude Code

Fixes #8114

Fixes #14377

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

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues remain.

Summary

The launcher writes a temporary PID marker while moving focus between monitors. Screensavers skip focus-based dismissal only while that PID is alive.

  • Screensavers stay open while the launcher moves focus between monitors.

Reviews (4) · Last reviewed commit: "Make the interrupt case wait for the spa..." · Reviewed by Greptile

… launcher

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Comment thread bin/omarchy-screensaver Resolved
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The spawn sentinel from the first launch was still on disk, so the wait could end as soon as the marker appeared and signal the launcher before it spawned anything or reached its wait for a window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

The bug is real, and this fixes its cause. I tested it on a disposable Omarchy worker running this branch merged onto current quattro (cce8b1c), with foot as the terminal and a regular window on every output after the first. With quattro's two scripts, every screensaver was gone 3 s after the launcher returned in all 8 launches: 4 on three outputs where each screensaver terminal started 1.5 s late, and 4 on five outputs at foot's normal speed. In the slowed runs the launcher sat out a 5 s deadline, which is what #9713 captured. With this branch, every screensaver stayed up in all 9 launches: three outputs with a 1.5 s and a 3 s delay, and five outputs at normal speed. Focusing another window after the launch still dismissed them all within 2.5 s, and the marker was gone. test/shell.d/screensaver-launching-test.sh passes 6 of 6 runs and fails with the fix reverted. screensaver-workspace-test.sh, system-lock-test.sh and ./test/cli pass.

I pushed one commit to your branch, 19313cb. The interrupt case could signal the launcher before it spawned anything: the spawn sentinel from the first case was still on disk, so the wait stopped as soon as the marker appeared. It now clears the sentinel and requires a fresh spawn before sending SIGTERM, so it tests an interrupt during the wait for a window. I also linked #8114 and #14377, which describe the same failure.

Second opinion: Codex Medium reviewed it in two rounds and found nothing open on this head. Independence is not guaranteed. It found the sentinel problem in the test. It also raised two edge cases that are left as they are, because neither makes things worse than quattro:

  • Two launchers running at once, such as the idle timer and a manual force, share one marker, so the first to finish removes it while the other is still stepping through monitors. That falls back to quattro's behaviour. The launcher was already unserialized, and two launchers already double-spawn on quattro today.
  • If the launcher is SIGKILLed and its pid is later reused while screensavers are still up, losing focus stops dismissing them. A keypress or the lock still ends them.

Other open fixes in this area:

Codex, asked separately which of these to bring forward for this bug, chose this one for the same reason.

The full shell suite is not green on the worker, and this branch did not cause that: it has the same failures on quattro, most of them because node is missing from the worker image. This waits on the maintainer, and on the suite being green.

@omarchybot

Copy link
Copy Markdown
Collaborator

This now conflicts with quattro because the code it fixes is gone, not because the fix is wrong. #16800 (merge ce0ef48, 28 October) replaced the terminal screensaver with the native Wayland one: it deleted bin/omarchy-screensaver and turned bin/omarchy-launch-screensaver into a single exec /usr/lib/omarchy-screensaver/omarchy-screensaver "$@". The focus walk across monitors, the five-second openwindow wait and the focus-loss watchdog that this branch coordinates no longer exist anywhere on quattro (d7e39bf).

The native screensaver can't hit this bug. It is one process that puts an overlay layer surface on each output as the output appears, with no per-monitor spawn or deadline. A keyboard focus leaving a surface is explicitly not treated as a dismissal: in omacom/omarchy-screensaver, src/wayland.rs maps leave to FocusLeft, dismisses() accepts only KeyPressed, and the unit test output_focus_transfer_is_not_user_activity covers it. So the marker has nothing to set it and nothing to read it, and test/shell.d/screensaver-launching-test.sh runs a script that no longer exists. I did not port it or run it on a worker, because nothing in it applies to quattro.

Second opinion: Codex Medium and muse-wonder (High) each read quattro, the merged #16800 and the native source. Both agreed nothing in this branch or its test still applies, and that #8114, #9713 and #14377 describe failure paths the native screensaver removed. Independence is not guaranteed. The competing fixes #7102, #13475 and #15614 patch the same deleted scripts.

Thank you @juan-LARRAYA. Your diagnosis of the launcher's focus walk was right, and the replacement avoids that walk entirely. This waits on the maintainer, and I recommend closing it as superseded by #16800. If you can still make a screensaver close itself on several monitors with the native one, please open a new issue against it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

2 participants