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
9 changes: 9 additions & 0 deletions bin/omarchy-system-blank
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# omarchy:summary=Turn off displays and keyboard backlight for power saving
# omarchy:group=system
# omarchy:name=blank
# omarchy:examples=omarchy system blank

omarchy-brightness-keyboard off
omarchy-brightness-display off
2 changes: 1 addition & 1 deletion docs/omarchy-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Rules:
5. Third-party enabled ⇔ present; for full bar options that means `bar.id`.
First-party non-bar plugins are enabled unless listed in `disabledPlugins[]`.
6. `barWidget.allowMultiple: true` in the manifest permits multiple instances.
7. `idle.screensaver` and `idle.lock` are seconds since user idle began.
7. `idle.screensaver` and `idle.lock` are seconds since user idle began. `idle.blank` is optional and, when set, independently blanks the display (and keyboard backlight) at its own idle deadline without engaging the session lock — omit it to keep blanking tied to `idle.lock` as before.
8. `version: 1` is required.

`config/omarchy/shell.json` describes the fresh-install state. When no
Expand Down
19 changes: 18 additions & 1 deletion manual/13-toggles-idle-screensaver.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,24 @@ If you dismiss the screensaver before the lock deadline, that counts as activity

To stop locking on idle entirely, `Super + Ctrl + I` — or `omarchy toggle idle` — flips stay awake on, and the coffee cup indicator appears in the bar. That's the one to hit before a long presentation or a build you want to watch. Hit it again to go back to normal. `omarchy toggle idle status` prints the current state as JSON if you need it from a script.

This is about locking and the screensaver, not power. Suspend and hibernation have their own setup in [system sleep](36-system-sleep.md).
### Blanking the display without locking

Locking always blanks the display a few seconds after it engages, but you don't have to reach for the lock screen just to save power. Add a third number, `blank`, to turn off the display and keyboard backlight on its own schedule, independent of the lock:

```json
{
"version": 1,
"idle": {
"screensaver": 900,
"blank": 1200,
"lock": 86400
}
}
```

`blank` counts from the same idle start as the other two. Here the screensaver comes up at 15 minutes and the display powers off at 20 minutes, while the lock is effectively parked out at a full day. Any input wakes the display back up the same way it cancels the screensaver or an in-progress lock. Leave `blank` out entirely and nothing changes — the display keeps blanking only as part of locking, same as before.

This is about locking, the screensaver, and now display power — not suspend. Suspend and hibernation have their own setup in [system sleep](36-system-sleep.md).

### The screensaver

Expand Down
5 changes: 4 additions & 1 deletion shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ becomes the authoritative file — we do **not** deep-merge defaults back in.
entries with their own values.
7. **Idle timings are top-level.** `idle.screensaver` and `idle.lock`
are seconds since user idle began, so the default lock fires at 300s
even if the 150s screensaver starts first.
even if the 150s screensaver starts first. `idle.blank` is optional and,
when set, independently blanks the display and keyboard backlight at its
own deadline without engaging the lock — omit it to keep blanking tied to
`idle.lock` as before.
8. **`version: 1` is required** at the top level. The shell will fall back
to defaults rather than load an unknown version.

Expand Down
2 changes: 1 addition & 1 deletion shell/plugins/lock/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ Item {

Process {
id: blankProcess
command: ["bash", "-c", "omarchy-brightness-keyboard off; omarchy-brightness-display off"]
command: ["bash", "-c", "omarchy-system-blank"]
}

Timer {
Expand Down
7 changes: 7 additions & 0 deletions shell/plugins/services/idle/IdleModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ function secondsFromConfig(value, fallback) {
return Math.floor(n)
}

function blankEnabled(value) {
if (value === undefined || value === null) return false
var n = Number(value)
return isFinite(n) && n >= 0
}

function eventParts(event, count) {
try {
if (event && event.parse) return event.parse(count)
Expand Down Expand Up @@ -46,6 +52,7 @@ function screensaverWindowsAfter(windows, address, visible) {
if (typeof module !== "undefined") {
module.exports = {
secondsFromConfig: secondsFromConfig,
blankEnabled: blankEnabled,
eventParts: eventParts,
screensaverWindowsAfter: screensaverWindowsAfter
}
Expand Down
42 changes: 40 additions & 2 deletions shell/plugins/services/idle/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ Item {
readonly property var idleConfig: shell && shell.shellConfig && shell.shellConfig.idle ? shell.shellConfig.idle : ({})
readonly property int screensaverTimeoutSeconds: secondsFromConfig(idleConfig.screensaver, defaultScreensaverSeconds)
readonly property int lockTimeoutSeconds: secondsFromConfig(idleConfig.lock, defaultLockSeconds)
readonly property int firstIdleTimeoutSeconds: Math.min(screensaverTimeoutSeconds, lockTimeoutSeconds)
readonly property bool blankConfigured: IdleModel.blankEnabled(idleConfig.blank)
readonly property int blankTimeoutSeconds: secondsFromConfig(idleConfig.blank, 0)
readonly property int firstIdleTimeoutSeconds: Math.min(screensaverTimeoutSeconds, lockTimeoutSeconds, blankConfigured ? blankTimeoutSeconds : Number.MAX_SAFE_INTEGER)
readonly property int screensaverDelaySeconds: Math.max(0, screensaverTimeoutSeconds - firstIdleTimeoutSeconds)
readonly property int lockDelaySeconds: Math.max(0, lockTimeoutSeconds - firstIdleTimeoutSeconds)
readonly property int blankDelaySeconds: blankConfigured ? Math.max(0, blankTimeoutSeconds - firstIdleTimeoutSeconds) : 0
readonly property bool idleEnabled: stayAwakeStateLoaded && !stayAwake
readonly property string screensaverClass: "org.omarchy.screensaver"

Expand Down Expand Up @@ -68,10 +71,15 @@ Item {
runProcess(screensaverProcess, "screensaver", "[[ $(omarchy-shell lock isLocked 2>/dev/null) == \"true\" ]] || omarchy-launch-screensaver")
}

function blankDisplay() {
runProcess(blankProcess, "blank", "[[ $(omarchy-shell lock isLocked 2>/dev/null) == \"true\" ]] || omarchy-system-blank")
Comment on lines +74 to +75
}

function lockSystem(reason) {
logEvent("lock-system", reason || "requested")
screensaverTimer.stop()
lockTimer.stop()
blankTimer.stop()
screensaverLaunchGraceTimer.stop()
root.idledThisCycle = false
root.screensaverStartedThisCycle = false
Expand All @@ -85,7 +93,7 @@ Item {
return
}

logEvent("idle-cycle-start", "screensaver=" + root.screensaverTimeoutSeconds + " lock=" + root.lockTimeoutSeconds)
logEvent("idle-cycle-start", "screensaver=" + root.screensaverTimeoutSeconds + " lock=" + root.lockTimeoutSeconds + (root.blankConfigured ? " blank=" + root.blankTimeoutSeconds : ""))
root.idledThisCycle = true
root.screensaverStartedThisCycle = false
resetScreensaverWindows()
Expand All @@ -95,12 +103,23 @@ Item {

if (root.lockDelaySeconds === 0) lockSystem("lock-timeout-immediate")
else lockTimer.restart()

// Independent blanking only ever fires strictly before the lock deadline.
// At or after that point, lock/Service.qml's own post-lock timer owns
// blanking -- comparing absolute deadlines (rather than whichever delay
// happens to be 0) keeps that true even when blank and lock coincide
// exactly while screensaver is the earlier deadline.
if (root.blankConfigured && root.blankTimeoutSeconds < root.lockTimeoutSeconds) {
if (root.blankDelaySeconds === 0) blankDisplay()
else blankTimer.restart()
}
}

function cancelIdleCycle(reason) {
logEvent("idle-cycle-cancel", reason || "requested")
screensaverTimer.stop()
lockTimer.stop()
blankTimer.stop()
screensaverLaunchGraceTimer.stop()

if (root.idledThisCycle) runProcess(wakeProcess, "wake", "omarchy-system-wake")
Expand Down Expand Up @@ -188,17 +207,21 @@ Item {
screensaverStarted: root.screensaverStartedThisCycle,
screensaver: root.screensaverTimeoutSeconds,
lock: root.lockTimeoutSeconds,
blank: root.blankConfigured ? root.blankTimeoutSeconds : null,
screensaverDelay: root.screensaverDelaySeconds,
lockDelay: root.lockDelaySeconds,
blankDelay: root.blankConfigured ? root.blankDelaySeconds : null,
screensaverWindows: root.screensaverWindowCount,
timers: {
screensaver: screensaverTimer.running,
lock: lockTimer.running,
blank: blankTimer.running,
screensaverLaunchGrace: screensaverLaunchGraceTimer.running
},
processes: {
screensaver: screensaverProcess.running,
lock: lockProcess.running,
blank: blankProcess.running,
wake: wakeProcess.running
},
lastEvent: root.lastEvent,
Expand Down Expand Up @@ -269,6 +292,17 @@ Item {
onTriggered: if (root.idleEnabled && root.idledThisCycle) root.lockSystem("lock-timeout")
}

Timer {
id: blankTimer
interval: root.blankDelaySeconds * 1000
repeat: false
// shell.json reloads live: if idle.blank is removed while this timer is
// running, the interval binding above can drop to 0 and fire almost
// immediately. Recheck blankConfigured so a just-removed setting can't
// still blank the display.
onTriggered: if (root.idleEnabled && root.idledThisCycle && root.blankConfigured) root.blankDisplay()
}

Timer {
id: screensaverLaunchGraceTimer
interval: 3000
Expand All @@ -293,6 +327,10 @@ Item {
id: lockProcess
onExited: function(exitCode, exitStatus) { root.logEvent("process-exit", "lock exitCode=" + exitCode + " status=" + exitStatus) }
}
Process {
id: blankProcess
onExited: function(exitCode, exitStatus) { root.logEvent("process-exit", "blank exitCode=" + exitCode + " status=" + exitStatus) }
}
Process {
id: wakeProcess
onExited: function(exitCode, exitStatus) { root.logEvent("process-exit", "wake exitCode=" + exitCode + " status=" + exitStatus) }
Expand Down
2 changes: 1 addition & 1 deletion shell/plugins/services/idle/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Idle",
"version": "1.0.0",
"author": "Omarchy",
"description": "Quickshell-based idle detection for screensaver, lock, and display wake.",
"description": "Quickshell-based idle detection for screensaver, lock, optional independent display blanking, and wake.",
"kinds": [
"service"
],
Expand Down
9 changes: 9 additions & 0 deletions test/shell.d/idle-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ assertEqual(idle.secondsFromConfig('42.9', 10), 42, 'idle floors configured seco
assertEqual(idle.secondsFromConfig('-1', 10), 10, 'idle rejects negative seconds')
assertEqual(idle.secondsFromConfig('nope', 10), 10, 'idle rejects invalid seconds')

assertEqual(idle.blankEnabled(1200), true, 'idle treats a configured blank seconds value as enabled')
assertEqual(idle.blankEnabled('1200'), true, 'idle treats a configured blank seconds string as enabled')
assertEqual(idle.blankEnabled(0), true, 'idle treats an explicit zero blank seconds value as enabled')
assertEqual(idle.blankEnabled(undefined), false, 'idle treats a missing blank key as disabled')
assertEqual(idle.blankEnabled(null), false, 'idle treats a null blank key as disabled')
assertEqual(idle.blankEnabled('nope'), false, 'idle treats an invalid blank value as disabled rather than falling back to zero seconds')
assertEqual(idle.blankEnabled(-1), false, 'idle treats a negative blank value as disabled rather than falling back to zero seconds')
assertEqual(idle.blankEnabled(Infinity), false, 'idle treats a non-finite blank value as disabled')

assertDeepEqual(idle.eventParts({ data: 'a,b,c' }, 2), ['a', 'b', 'c'], 'idle parses raw event data')
assertDeepEqual(
idle.eventParts({ parse: function(count) { return ['parsed', count] } }, 4),
Expand Down