diff --git a/bin/omarchy-debug-idle b/bin/omarchy-debug-idle index 62a38cf10ad6..39eb0588df36 100755 --- a/bin/omarchy-debug-idle +++ b/bin/omarchy-debug-idle @@ -49,7 +49,7 @@ hyprctl clients -j 2>/dev/null \ section "Screensaver detector" if hyprctl clients -j 2>/dev/null | jq -e '.[] | select(.class == "org.omarchy.screensaver" or .initialClass == "org.omarchy.screensaver")' >/dev/null; then echo "running-window" -elif pgrep -f '[o]rg.omarchy.screensaver' >/dev/null; then +elif pgrep -f '^([^ ]*/)?(alacritty|ghostty|foot|kitty) .*--(class|app-id)=org\.omarchy\.screensaver( |$)' >/dev/null; then echo "running-process" elif omarchy-toggle-enabled screensaver-off; then echo "disabled" diff --git a/bin/omarchy-launch-screensaver b/bin/omarchy-launch-screensaver index 3db5acfe9078..8e7a91724400 100755 --- a/bin/omarchy-launch-screensaver +++ b/bin/omarchy-launch-screensaver @@ -3,7 +3,7 @@ # omarchy:summary=Launch the Omarchy screensaver in the default terminal on the system with the correct font configuration. # Exit early if screensaver is already running -pgrep -f '[o]rg.omarchy.screensaver' && exit 0 +pgrep -f '^([^ ]*/)?(alacritty|ghostty|foot|kitty) .*--(class|app-id)=org\.omarchy\.screensaver( |$)' && exit 0 # Allow screensaver to be turned off but also force started if omarchy-toggle-enabled screensaver-off && [[ $1 != "force" ]]; then diff --git a/bin/omarchy-screensaver b/bin/omarchy-screensaver index 44cbfad2c367..991a97fec886 100755 --- a/bin/omarchy-screensaver +++ b/bin/omarchy-screensaver @@ -7,9 +7,10 @@ screensaver_in_focus() { } exit_screensaver() { - hyprctl eval 'hl.config({ cursor = { invisible = false } })' &>/dev/null || hyprctl keyword cursor:invisible false &>/dev/null || true + # The startup reveal owns the cursor while it is still pending. + hyprctl eval 'if not omarchy_startup_cursor_pending then hl.config({ cursor = { invisible = false } }) end' &>/dev/null || hyprctl keyword cursor:invisible false &>/dev/null || true pkill -x ttfx 2>/dev/null - pkill -f '[o]rg.omarchy.screensaver' 2>/dev/null + pkill -f '^([^ ]*/)?(alacritty|ghostty|foot|kitty) .*--(class|app-id)=org\.omarchy\.screensaver( |$)' 2>/dev/null exit 0 } diff --git a/bin/omarchy-system-lock b/bin/omarchy-system-lock index 53e4ca5a0efb..58930d5302f2 100755 --- a/bin/omarchy-system-lock +++ b/bin/omarchy-system-lock @@ -23,4 +23,4 @@ fi pkill -x ttfx 2>/dev/null || true # ttfx handles SIGTERM asynchronously, so keep its terminal alive until it exits. timeout 1s pidwait -x ttfx 2>/dev/null || true -pkill -f '[o]rg.omarchy.screensaver' 2>/dev/null || true +pkill -f '^([^ ]*/)?(alacritty|ghostty|foot|kitty) .*--(class|app-id)=org\.omarchy\.screensaver( |$)' 2>/dev/null || true diff --git a/shell/plugins/services/idle/Service.qml b/shell/plugins/services/idle/Service.qml index d0ed8a2676bf..92f75732a2ae 100644 --- a/shell/plugins/services/idle/Service.qml +++ b/shell/plugins/services/idle/Service.qml @@ -29,6 +29,10 @@ Item { readonly property int lockDelaySeconds: IdleModel.delayAfterFirstIdle(lockTimeoutSeconds, firstIdleTimeoutSeconds) readonly property bool idleEnabled: stayAwakeStateLoaded && !stayAwake readonly property string screensaverClass: "org.omarchy.screensaver" + // The screensaver hides the cursor and shows it again on its way out, but a + // terminal that dies without running that exit would leave the desktop with + // no cursor. The startup reveal owns the cursor while it is still pending. + readonly property string showCursorLua: "if not omarchy_startup_cursor_pending then hl.config({ cursor = { invisible = false } }) end" property bool stayAwake: false property bool stayAwakeStateLoaded: false @@ -40,6 +44,9 @@ Item { property string lastEventAt: "" property var screensaverWindows: ({}) property int screensaverWindowCount: 0 + // Every open screensaver window, kept apart from the idle cycle's own count, + // which lock and cancel clear before the windows have actually closed. + property var cursorHidingWindows: ({}) function secondsFromConfig(value, fallback) { return IdleModel.secondsFromConfig(value, fallback) @@ -155,6 +162,16 @@ Item { root.cancelIdleCycle("screensaver-dismissed") } + function trackCursorHidingWindow(address, visible) { + var next = IdleModel.screensaverWindowsAfter(root.cursorHidingWindows, address, visible) + root.cursorHidingWindows = next.windows + if (!visible && next.count === 0) { + logEvent("cursor-show", "last screensaver window closed") + cursorShowProcess.running = false + cursorShowProcess.running = true + } + } + function eventParts(event, count) { return IdleModel.eventParts(event, count) } @@ -163,10 +180,14 @@ Item { var name = String(event && event.name ? event.name : "") if (name === "openwindow") { var open = eventParts(event, 4) - if (String(open[2] || "") === root.screensaverClass) root.handleScreensaverWindowOpened(open[0]) + if (String(open[2] || "") === root.screensaverClass) { + root.trackCursorHidingWindow(open[0], true) + root.handleScreensaverWindowOpened(open[0]) + } } else if (name === "closewindow") { var close = eventParts(event, 1) var address = String(close[0] || "") + if (root.cursorHidingWindows[address]) root.trackCursorHidingWindow(address, false) if (root.screensaverWindows[address]) root.handleScreensaverWindowClosed(address) } } @@ -316,6 +337,11 @@ Item { onExited: function(exitCode, exitStatus) { root.logEvent("process-exit", "wake exitCode=" + exitCode + " status=" + exitStatus) } } + Process { + id: cursorShowProcess + command: ["hyprctl", "eval", root.showCursorLua] + } + Process { id: stayAwakeStateProbe command: ["bash", "-c", "mkdir -p \"$HOME/.local/state/omarchy/indicators\"; if [[ -f $HOME/.local/state/omarchy/indicators/stay-awake ]]; then echo yes; else echo no; fi"] diff --git a/test/shell.d/system-lock-test.sh b/test/shell.d/system-lock-test.sh index da79eac045e0..20d21d05efcd 100755 --- a/test/shell.d/system-lock-test.sh +++ b/test/shell.d/system-lock-test.sh @@ -31,6 +31,6 @@ mapfile -t shutdown < <(rg '^(pkill|timeout) ' "$call_log") fail "system lock stops ttfx before closing its terminal" "calls: ${shutdown[*]}" [[ ${shutdown[1]} == "timeout 1s pidwait -x ttfx" ]] || fail "system lock waits for ttfx to exit" "calls: ${shutdown[*]}" -[[ ${shutdown[2]} == "pkill -f [o]rg.omarchy.screensaver" ]] || +[[ ${shutdown[2]} == "pkill -f ^([^ ]*/)?(alacritty|ghostty|foot|kitty) .*--(class|app-id)=org\.omarchy\.screensaver( |$)" ]] || fail "system lock closes the screensaver terminal after ttfx exits" "calls: ${shutdown[*]}" pass "system lock waits for ttfx before closing its terminal"