Repository navigation
Don't treat a screensaver closed by losing every output as a dismissal #15244
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import QtQuick | ||
| import Quickshell | ||
|
|
||
| ShellRoot { | ||
| id: root | ||
|
|
||
| readonly property string rootPath: Quickshell.env("OMARCHY_PATH") | ||
| readonly property string resultPath: Quickshell.env("OMARCHY_QML_TEST_RESULT") | ||
| readonly property string wakeLog: Quickshell.env("OMARCHY_WAKE_LOG") | ||
| property var failures: [] | ||
| property int checks: 0 | ||
| property int step: 0 | ||
| property var service: null | ||
|
|
||
| readonly property var realScreen: ({ name: "DP-1", width: 1920, height: 1080 }) | ||
| readonly property var fallbackScreen: ({ name: "FALLBACK", width: 1920, height: 1080 }) | ||
| readonly property string saver: "org.omarchy.screensaver" | ||
|
|
||
| Item { id: host } | ||
|
|
||
| function check(condition, message) { | ||
| checks += 1 | ||
| if (!condition) failures.push(message) | ||
| } | ||
|
|
||
| function mark(name) { | ||
| var quoted = "'" + name.replace(/'/g, "'\\''") + "'" | ||
| Quickshell.execDetached(["bash", "-c", "echo \"S " + name + "\" >> \"$1\"", "_", wakeLog]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| // A cycle that idled with the screensaver up on a window at 0x1, as the | ||
| // idle service sees it once the screensaver has opened. | ||
| function begin(name, screens) { | ||
| if (service) service.destroy() | ||
| var component = Qt.createComponent("file://" + rootPath + "/shell/plugins/services/idle/Service.qml", Component.PreferSynchronous) | ||
| if (component.status !== Component.Ready) throw new Error(component.errorString()) | ||
| service = component.createObject(host, { outputScreens: screens }) | ||
| if (!service) throw new Error(component.errorString()) | ||
| service.stayAwakeStateLoaded = true | ||
| service.idledThisCycle = true | ||
| service.screensaverStartedThisCycle = true | ||
| service.handleHyprlandEvent({ name: "openwindow", data: "0x1,1,org.omarchy.screensaver,t" }) | ||
| check(service.screensaverWindowCount === 1, name + ": the screensaver window is tracked") | ||
| mark(name) | ||
| } | ||
|
|
||
| function closeSaver() { service.handleHyprlandEvent({ name: "closewindow", data: "0x1" }) } | ||
|
|
||
| property var scenarios: [ | ||
| function() { | ||
| begin("no-outputs-close", []) | ||
| closeSaver() | ||
| check(service.idledThisCycle, "closing with no outputs keeps the cycle") | ||
| service.handleActiveSignal() | ||
| check(service.idledThisCycle, "resumed after the output loss keeps the cycle") | ||
| }, | ||
| function() { | ||
| begin("fallback-only-close", [fallbackScreen]) | ||
| closeSaver() | ||
| check(service.idledThisCycle, "a FALLBACK-only screen list counts as no outputs") | ||
| service.handleActiveSignal() | ||
| check(service.idledThisCycle, "resumed with only FALLBACK keeps the cycle") | ||
| }, | ||
| function() { | ||
| begin("stale-list-monitorremoved", [realScreen]) | ||
| service.handleHyprlandEvent({ name: "monitorremoved", data: "DP-1" }) | ||
| closeSaver() | ||
| check(service.idledThisCycle, "monitorremoved before a stale screen list keeps the cycle") | ||
| service.handleActiveSignal() | ||
| check(service.idledThisCycle, "resumed right after monitorremoved keeps the cycle") | ||
| }, | ||
| function() { | ||
| begin("fallback-removed-close", [realScreen]) | ||
| service.handleHyprlandEvent({ name: "monitorremoved", data: "FALLBACK" }) | ||
| closeSaver() | ||
| check(!service.idledThisCycle, "removing only FALLBACK is not an output loss") | ||
| }, | ||
| function() { | ||
| begin("real-dismissal", [realScreen]) | ||
| closeSaver() | ||
| check(!service.idledThisCycle, "closing the screensaver with outputs present still cancels") | ||
| }, | ||
| function() { | ||
| begin("real-activity", [realScreen]) | ||
| service.handleHyprlandEvent({ name: "closewindow", data: "0x9" }) | ||
| check(service.idledThisCycle, "closing an unrelated window leaves the cycle") | ||
| service.screensaverStartedThisCycle = false | ||
| service.handleActiveSignal() | ||
| check(!service.idledThisCycle, "resumed with outputs present is real activity") | ||
| } | ||
| ] | ||
|
|
||
| function finish() { | ||
| if (service) service.destroy() | ||
| var payload = JSON.stringify({ ok: failures.length === 0, checks: checks, failures: failures }) | ||
| var quoted = "'" + payload.replace(/'/g, "'\\''") + "'" | ||
| Quickshell.execDetached(["bash", "-c", "printf '%s' " + quoted + " > \"$1\"", "_", resultPath]) | ||
| } | ||
|
|
||
| // Each scenario gets time for its wake stub (if any) to log before the next. | ||
| Timer { | ||
| interval: 700 | ||
| repeat: true | ||
| running: true | ||
| onTriggered: { | ||
| if (root.step >= root.scenarios.length) { | ||
| stop() | ||
| root.finish() | ||
| return | ||
| } | ||
| try { | ||
| root.scenarios[root.step]() | ||
| } catch (error) { | ||
| root.failures.push(String(error)) | ||
| } | ||
| root.step += 1 | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| TMPDIR="" | ||
| QS_PID="" | ||
|
|
||
| cleanup() { | ||
| if [[ -n $QS_PID ]] && kill -0 "$QS_PID" 2>/dev/null; then | ||
| kill "$QS_PID" 2>/dev/null || true | ||
| wait "$QS_PID" 2>/dev/null || true | ||
| fi | ||
| if [[ -n $TMPDIR && -d $TMPDIR ]]; then | ||
| rm -rf "$TMPDIR" | ||
| fi | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| require_compositor "idle output loss test" | ||
|
|
||
| if ! command -v quickshell >/dev/null 2>&1; then | ||
| skip "quickshell not installed; skipping idle output loss test" | ||
| exit 0 | ||
| fi | ||
|
|
||
| require_command jq | ||
|
|
||
| TMPDIR=$(mktemp -d) | ||
| result="$TMPDIR/result.json" | ||
| log="$TMPDIR/quickshell.log" | ||
| wakes="$TMPDIR/wakes.log" | ||
| config_dir="$TMPDIR/idle-output-loss" | ||
| mkdir -p "$config_dir" "$TMPDIR/home" "$TMPDIR/stubs" | ||
| cp "$SHELL_TEST_DIR/fixtures/idle-output-loss/shell.qml" "$config_dir/shell.qml" | ||
| ln -s "$ROOT/shell/Ui" "$config_dir/Ui" | ||
| ln -s "$ROOT/shell/Commons" "$config_dir/Commons" | ||
|
|
||
| # Stub the boundary: the idle service's wake command only records that it ran. | ||
| cat >"$TMPDIR/stubs/omarchy-system-wake" <<STUB | ||
| #!/bin/bash | ||
| echo wake >> "$wakes" | ||
| STUB | ||
| chmod +x "$TMPDIR/stubs/omarchy-system-wake" | ||
|
|
||
| OMARCHY_PATH="$ROOT" \ | ||
| OMARCHY_QML_TEST_RESULT="$result" \ | ||
| OMARCHY_WAKE_LOG="$wakes" \ | ||
| HOME="$TMPDIR/home" \ | ||
| XDG_CONFIG_HOME="$TMPDIR/home/.config" \ | ||
| XDG_CACHE_HOME="$TMPDIR/home/.cache" \ | ||
| XDG_STATE_HOME="$TMPDIR/home/.local/state" \ | ||
| QML2_IMPORT_PATH="$ROOT/shell${QML2_IMPORT_PATH:+:$QML2_IMPORT_PATH}" \ | ||
| QML_IMPORT_PATH="$ROOT/shell${QML_IMPORT_PATH:+:$QML_IMPORT_PATH}" \ | ||
| PATH="$TMPDIR/stubs:$ROOT/bin:$PATH" \ | ||
| quickshell -p "$config_dir" --no-color >"$log" 2>&1 & | ||
|
Comment on lines
+56
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test puts the wake stub first in |
||
| QS_PID=$! | ||
|
|
||
| for _ in {1..120}; do | ||
| [[ -s $result ]] && break | ||
| if ! kill -0 "$QS_PID" 2>/dev/null; then | ||
| sed -n '1,220p' "$log" >&2 | ||
| fail "idle output loss quickshell exited before writing result" | ||
| fi | ||
| sleep 0.1 | ||
| done | ||
|
|
||
| [[ -s $result ]] || { | ||
| sed -n '1,220p' "$log" >&2 | ||
| fail "idle output loss test timed out" | ||
| } | ||
|
|
||
| if ! jq -e '.ok == true' "$result" >/dev/null; then | ||
| jq . "$result" >&2 | ||
| sed -n '1,220p' "$log" >&2 | ||
| fail "idle service keeps the cycle through output loss and still cancels on real activity" | ||
| fi | ||
|
|
||
| # The wake stub runs asynchronously; each scenario marks its own section. | ||
| expected=$'S no-outputs-close\nS fallback-only-close\nS stale-list-monitorremoved\nS fallback-removed-close\nwake\nS real-dismissal\nwake\nS real-activity\nwake' | ||
| if [[ $(cat "$wakes") != "$expected" ]]; then | ||
| printf 'Wake log:\n' >&2 | ||
| cat "$wakes" >&2 | ||
| sed -n '1,120p' "$log" >&2 | ||
| fail "wake runs only for real dismissal and activity, never for output loss" | ||
| fi | ||
|
|
||
| pass "idle service keeps the cycle through output loss and still cancels on real activity" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing one monitor starts
outputLossTimereven when another monitor remains connected. For the next three seconds,outputsLost()ignores genuine screensaver dismissal and activity on that remaining monitor. The pending lock stays armed and can lock the session after the user has returned. Limit the hold to losing all usable outputs, and stop suppressing real dismissal once an output is available.Knowledge Base Used: Shell UI and desktop interactions