Skip to content

Exit the screensaver on mouse click - #16519

Closed
joshuaswarren wants to merge 4 commits into
omacom:quattrofrom
joshuaswarren:screensaver-click-exit
Closed

joshuaswarren wants to merge 4 commits into
omacom:quattrofrom
joshuaswarren:screensaver-click-exit

Conversation

@joshuaswarren

Copy link
Copy Markdown

Problem

A mouse click does nothing while the screensaver runs. Only a key press exits it.

Cause

The screensaver loop waits for a byte from the terminal:

while pgrep -t "$tty" -x ttfx >/dev/null; do
  if read -n1 -t 1 || ! screensaver_in_focus; then
    exit_screensaver
  fi
done

A key press produces a byte. A click produces none. Terminals only report mouse input when a program asks for it, so every click was dropped.

Change

Ask for button-press reports at startup. Stop asking in the exit path:

printf '\033[?1000h\033[?1006h'    # at startup
printf '\033[?1000l\033[?1006l'    # in exit_screensaver

A click now delivers input bytes. The existing read exits the screensaver, same as a key press. Mode 1000 reports presses only, so cursor motion alone cannot exit. Mode 1006 is the modern encoding, safe at large coordinates. This is standard xterm mouse reporting. It works in foot, Alacritty, Ghostty and Kitty, every terminal the launcher supports.

Verification

On Apple Silicon hardware, with the patched script installed:

  • A key press still exits the screensaver. The window closes. Tested.
  • The new escape bytes are emitted exactly as written. Verified with a hex dump.
  • Exit by focus loss and by signal is unchanged. The disable sequence runs in the shared exit path first.

A live click was not tested end to end. The host runs headless over SSH, and no tool there could deliver a real pointer click to the compositor. With reporting on, a click takes the same input path as a key press. The last step still needs one manual check on a desktop with a mouse. The change is two lines and reverts by removing them.

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with non-blocking test concerns.

Findings

  1. P2 Test passes through focus loss ▶
  2. P2 Required Bash options are missing ▶

Summary

The PR enables terminal mouse reports so clicks reach the screensaver’s existing input exit path.

  • A mouse click now exits the screensaver.

Reviews (4) · Last reviewed commit: "test: keep screensaver click regression ..." · Reviewed by Greptile

The screensaver exits on any byte from the terminal, so a key press ends
it. A mouse click produces no bytes: the terminal never reports mouse
input to the shell unless the program asks for it. Ask for button-press
reporting at startup and stop asking in the exit path, so a click now
delivers input and ends the screensaver the same way a key press does.
@joshuaswarren
joshuaswarren force-pushed the screensaver-click-exit branch from 6139ed1 to 0dc6919 Compare October 26, 2026 20:52
@@ -0,0 +1,156 @@
#!/bin/bash

source "$(dirname "$0")/base-test.sh"

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.

P2 Required Bash options are missing

The new test omits set -euo pipefail, which the contributor guide requires before sourcing base-test.sh. Without these options, failed setup commands can leave the test running with incomplete files. Add the required line before merging.

Suggested change
source "$(dirname "$0")/base-test.sh"
set -euo pipefail
source "$(dirname "$0")/base-test.sh"

File Used: docs/testing.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

source "$(dirname "$0")/base-test.sh"

# Keep the real read/exit path; desktop commands must not affect this session.
hyprctl() { return 0; }

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.

P2 Test passes through focus loss

The new hyprctl stub returns no window data, so screensaver_in_focus fails whenever read fails. The script then exits through focus loss and prints the same disable bytes the test expects. This lets the test pass even if input no longer exits the screensaver. Have the stub report the screensaver as focused so only the supplied input can trigger a successful exit.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for working on this. #16800, now merged, replaced the terminal screensaver with a native Wayland overlay that dismisses itself on any key, click, scroll or mouse movement, so this fix to the terminal version is no longer needed. Closing in favour of it.

@omarchybot omarchybot closed this Oct 28, 2026
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.

2 participants