Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/omarchy-debug-idle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion bin/omarchy-launch-screensaver
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions bin/omarchy-screensaver
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion bin/omarchy-system-lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 27 additions & 1 deletion shell/plugins/services/idle/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)

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.

P1 Restart leaves screensavers untracked

After a shell restart or crash recovery, cursorHidingWindows starts empty even if screensaver windows are still open. This check then ignores those windows when they close. If their terminal dies without running exit_screensaver, the cursor stays hidden. Seed the map from existing screensaver windows when the service starts, alongside watching new events.

if (root.screensaverWindows[address]) root.handleScreensaverWindowClosed(address)
}
}
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion test/shell.d/system-lock-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"