Skip to content

fix(lock): deferred lock when no monitor is connected blocks suspend#2998

Open
mattvilim wants to merge 1 commit into
noctalia-dev:mainfrom
mattvilim:deferred-lock-suspend-fix
Open

fix(lock): deferred lock when no monitor is connected blocks suspend#2998
mattvilim wants to merge 1 commit into
noctalia-dev:mainfrom
mattvilim:deferred-lock-suspend-fix

Conversation

@mattvilim

@mattvilim mattvilim commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

When a suspend with lock_before_suspend=true behavior is triggered but no monitor is connected, the computer never suspends.

Steps to reproduce:

  1. Configure suspend behavior
[idle.behavior.suspend]
enabled = true
timeout = 10 # Just 10 seconds to make it happen quickly
lock_before_suspend = true
command = "noctalia:session suspend"
  1. Unplug monitor and wait 10 seconds (suspend never happens)
  2. Re-plug monitor and computer immediately suspends

Motivation

Commit 7e013e8 fixed an issue where idle lock behavior triggered when no monitor is connected would cause a lock screen crash (Niri red screen). The fix deferred lock until a monitor reconnects. As as a side effect, the suspend is also deferred, so unplugging a monitor will cause the computer never to suspend. On reconnecting the monitor, the computer immediately suspends.

As a side note, [idle.behavior.suspend].lock_before_suspend isn't documented. Not sure if there's a reason to keep it if the user can just set command = "noctalia:session lock-and-suspend" as the suspend command? This fix applies to both cases.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Build / packaging

Related Issue

N/A

Testing

I tested the following cases both with/without unplugging monitor before idle triggers, and it fixes both.

  1. lock-and-suspend with lock_before_suspend = false
[idle.behavior.suspend]
enabled = true
timeout = 10
lock_before_suspend = false
command = "noctalia:session lock-and-suspend"
  1. suspend with lock_before_suspend = true
[idle.behavior.suspend]
enabled = true
timeout = 10
lock_before_suspend = true
command = "noctalia:session suspend"

Manual Coverage

  • Tested on Niri
  • Tested on Hyprland
  • Tested on Sway
  • Tested on another compositor:
  • Tested with different bar positions and density settings
  • Tested at different interface scaling values
  • Tested with multiple monitors

Screenshots / Videos

N/A

Checklist

  • This PR is ready for review, or it is marked as Draft.
  • I read and followed the relevant guidance in CONTRIBUTING.md.
  • I ran just format with clang-format v22+ installed, or this PR has no code changes.
  • I ran the relevant build or test commands, or explained why they were not run.
  • I self-reviewed the changes.
  • I checked for new warnings or errors.
  • I will update end-user documentation after merge, or this PR does not change user-facing configuration or behavior.
  • I added or updated assets/translations/en.json, or this PR adds no new user-facing strings.
  • I did not edit non-English translation files unless this PR is explicitly for translation tooling, an import/export sync, or a maintainer-requested locale change.
  • I used the existing canonical names for config keys, IPC names, paths, and identifiers.

Additional Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant