Repository navigation
Keep the screensaver up until it has been focused once #12258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
z23
wants to merge
6
commits into
omacom:quattro
Choose a base branch
from
z23:fix/screensaver-focus-race
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
89b4f53
Keep the screensaver up until it has been focused once
z23 7514816
Bound a screensaver that never takes focus
z23 b359a76
Restore the screensaver script modes and test --idle
z23 7796187
Keep the screensaver test non-executable
z23 fb1f4a7
Exercise screensaver idle parsing and terminal launch arguments
z23 2518786
Dismiss idle screensavers on input without requiring focus
z23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| require_command jq | ||
|
|
||
| test_tmp=$(mktemp -d) | ||
| trap 'rm -rf "$test_tmp"' EXIT | ||
| mock_bin="$test_tmp/bin" | ||
| call_log="$test_tmp/calls" | ||
| mkdir -p "$mock_bin" "$test_tmp/home" "$test_tmp/runtime" | ||
|
|
||
| cat >"$mock_bin/pgrep" <<'SH' | ||
| #!/bin/bash | ||
| exit 1 | ||
| SH | ||
| cat >"$mock_bin/omarchy-toggle-enabled" <<'SH' | ||
| #!/bin/bash | ||
| exit 1 | ||
| SH | ||
| cat >"$mock_bin/omarchy-hyprland-monitor-focused" <<'SH' | ||
| #!/bin/bash | ||
| printf 'DP-1\n' | ||
| SH | ||
| cat >"$mock_bin/xdg-terminal-exec" <<'SH' | ||
| #!/bin/bash | ||
| printf '%s\n' "$TEST_TERMINAL" | ||
| SH | ||
| cat >"$mock_bin/hyprctl" <<'SH' | ||
| #!/bin/bash | ||
| if [[ $1 == "monitors" ]]; then | ||
| printf '[{"name":"DP-1"}]\n' | ||
| else | ||
| printf '%s\n' "$*" >>"$CALL_LOG" | ||
| fi | ||
| SH | ||
| cat >"$mock_bin/socat" <<'SH' | ||
| #!/bin/bash | ||
| printf 'openwindow>>1,1,org.omarchy.screensaver,Screensaver\n' | ||
| SH | ||
| chmod +x "$mock_bin"/* | ||
|
|
||
| # Run the actual launcher with all compositor, process, and event-stream calls | ||
| # stubbed. Check the command it sends, rather than the array's source spelling. | ||
| for terminal in Alacritty ghostty foot kitty; do | ||
| for mode in manual idle; do | ||
| args=() | ||
| [[ $mode == "idle" ]] && args=(--idle) | ||
| : >"$call_log" | ||
| HOME="$test_tmp/home" XDG_RUNTIME_DIR="$test_tmp/runtime" \ | ||
| HYPRLAND_INSTANCE_SIGNATURE=test OMARCHY_PATH="$ROOT" \ | ||
| PATH="$mock_bin:$PATH" TEST_TERMINAL="$terminal" CALL_LOG="$call_log" \ | ||
| bash "$ROOT/bin/omarchy-launch-screensaver" "${args[@]}" | ||
|
|
||
| mapfile -t launches < <(rg 'hl\.dsp\.exec_cmd' "$call_log") | ||
| (( ${#launches[@]} == 1 )) || fail "$terminal $mode launches one screensaver" | ||
| if [[ $mode == "idle" ]]; then | ||
| [[ ${launches[0]} == *"-e omarchy-screensaver --idle "* ]] || | ||
| fail "$terminal forwards --idle to the screensaver" "${launches[0]}" | ||
| else | ||
| [[ ${launches[0]} == *"-e omarchy-screensaver "* && ${launches[0]} != *"--idle"* ]] || | ||
| fail "$terminal manual launch stays on the manual path" "${launches[0]}" | ||
| fi | ||
| pass "$terminal $mode forwards the correct screensaver arguments" | ||
| done | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| require_command jq | ||
| require_command rg | ||
|
|
||
| if rg -q 'read -n1 -t 1 \|\| ! screensaver_in_focus' "$ROOT/bin/omarchy-screensaver"; then | ||
| fail "screensaver does not treat the first unfocused poll as dismissal" | ||
| fi | ||
| grep -Fq 'read -n1 -t 1 || screensaver_lost_focus' "$ROOT/bin/omarchy-screensaver" || | ||
| fail "screensaver watchdog dismisses through screensaver_lost_focus" | ||
| grep -Fq 'omarchy-launch-screensaver --idle' "$ROOT/shell/plugins/services/idle/Service.qml" || | ||
| fail "idle cycle launches the screensaver with --idle" | ||
| grep -Fq 'omarchy-screensaver --idle' "$ROOT/bin/omarchy-launch-screensaver" || | ||
| fail "screensaver launcher forwards --idle" | ||
| pass "screensaver does not treat the first unfocused poll as dismissal" | ||
|
|
||
| test_tmp=$(mktemp -d) | ||
| trap 'rm -rf "$test_tmp"' EXIT | ||
|
|
||
| mock_bin="$test_tmp/bin" | ||
| window_file="$test_tmp/window.json" | ||
| mkdir -p "$mock_bin" | ||
|
|
||
| cat >"$mock_bin/hyprctl" <<'SH' | ||
| #!/bin/bash | ||
|
|
||
| if [[ $1 == activewindow && $2 == -j ]]; then | ||
| cat "$HYPRCTL_WINDOW" | ||
| exit 0 | ||
| fi | ||
| exit 0 | ||
| SH | ||
| chmod +x "$mock_bin/hyprctl" | ||
|
|
||
| write_window() { | ||
| printf '{"class":"%s"}\n' "$1" >"$window_file" | ||
| } | ||
|
|
||
| export PATH="$mock_bin:$PATH" | ||
| export HYPRCTL_WINDOW="$window_file" | ||
| source "$ROOT/bin/omarchy-screensaver" | ||
|
|
||
| write_window foot | ||
| screensaver_seen_focus=0 | ||
| if screensaver_lost_focus; then | ||
| fail "screensaver stays up before it has been focused" | ||
| fi | ||
| if screensaver_lost_focus; then | ||
| fail "screensaver stays up across repeated unfocused polls before first focus" | ||
| fi | ||
| pass "screensaver stays up before it has been focused" | ||
|
|
||
| write_window org.omarchy.screensaver | ||
| if screensaver_lost_focus; then | ||
| fail "screensaver stays up once it is focused" | ||
| fi | ||
| (( screensaver_seen_focus == 1 )) || fail "screensaver records that it has been focused" | ||
| pass "screensaver stays up once it is focused" | ||
|
|
||
| write_window foot | ||
| if screensaver_lost_focus; then | ||
| pass "screensaver dismisses after losing focus" | ||
| else | ||
| fail "screensaver dismisses after losing focus" | ||
| fi | ||
|
|
||
| write_window foot | ||
| screensaver_seen_focus=0 | ||
| screensaver_unfocused_polls=0 | ||
| screensaver_idle=0 | ||
| gave_up=0 | ||
| for ((i = 0; i < screensaver_unfocused_limit; i++)); do | ||
| if screensaver_lost_focus; then | ||
| gave_up=1 | ||
| break | ||
| fi | ||
| done | ||
| ((gave_up == 1)) || fail "manual screensaver gives up when it never receives focus" | ||
| pass "manual screensaver gives up when it never receives focus" | ||
|
|
||
| write_window foot | ||
| screensaver_seen_focus=0 | ||
| screensaver_unfocused_polls=0 | ||
| screensaver_idle=1 | ||
| for ((i = 0; i < screensaver_unfocused_limit + 2; i++)); do | ||
| if screensaver_lost_focus; then | ||
| fail "idle screensaver keeps waiting for focus" | ||
| fi | ||
| done | ||
| pass "idle screensaver keeps waiting for focus" | ||
|
|
||
| screensaver_idle=0 | ||
| source "$ROOT/bin/omarchy-screensaver" --idle | ||
| ((screensaver_idle == 1)) || fail "screensaver --idle is recorded before the watchdog runs" | ||
| for ((i = 0; i < screensaver_unfocused_limit + 2; i++)); do | ||
| if screensaver_lost_focus; then | ||
| fail "parsed --idle keeps an unfocused screensaver waiting" | ||
| fi | ||
| done | ||
| screensaver_idle=0 | ||
| source "$ROOT/bin/omarchy-screensaver" | ||
| ((screensaver_idle == 0)) || fail "screensaver without --idle stays on the manual path" | ||
| pass "screensaver parses --idle before the source guard and keeps waiting for focus" | ||
|
|
||
| if rg -n -- '(-e|--) omarchy-screensaver( |$)' "$ROOT/bin/omarchy-launch-screensaver"; then | ||
| fail "terminal launchers must forward the screensaver command including --idle" | ||
| fi | ||
| pass "screensaver launcher has no bare terminal command that drops --idle" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.