Fix NVIDIA suspend hard-freeze when hyprlock is active#5283
Fix NVIDIA suspend hard-freeze when hyprlock is active#5283jpmsantana wants to merge 13 commits intobasecamp:devfrom
Conversation
hyprlock holds an active DRM/GBM context on the GPU that prevents the nvidia_drm suspend callback from checkpointing GPU state cleanly. The kernel hangs at PM: suspend entry (deep) with no recovery possible. Add a system-sleep hook (nvidia-hyprlock) that kills hyprlock just before the kernel DRM checkpoint fires — after hypridle's inhibit_sleep window, so the session is already locked. Also update after_sleep_cmd to relaunch hyprlock before enabling the display on resume, preventing a window where the unlocked desktop is briefly visible. Fixes basecamp#5277
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a workaround for NVIDIA suspend hangs by ensuring hyprlock is not holding a DRM/GBM context at suspend time, and restores locking behavior early on resume to avoid briefly exposing the unlocked desktop.
Changes:
- Add a
systemdsystem-sleep hook that killshyprlockright before suspend on NVIDIA systems. - Update Hypridle’s
after_sleep_cmdto re-lock before turning the display back on. - Add a migration to deploy the hook and update existing user Hypridle configs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| migrations/1776042000.sh | Installs the system-sleep hook on NVIDIA systems and migrates user Hypridle config. |
| install/config/hardware/nvidia.sh | Ensures fresh NVIDIA installs also deploy the system-sleep hook. |
| default/systemd/system-sleep/nvidia-hyprlock | New suspend hook that terminates hyprlock during the pre sleep phase. |
| config/hypr/hypridle.conf | Changes resume command order to re-lock before DPMS is re-enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add missing shebang to the migration and extract the nvidia-hyprlock hook installation into a shared script (nvidia-suspend-hook.sh) sourced by both the NVIDIA installer and the migration, eliminating duplication.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…vs source - Install hook to /etc/systemd/system-sleep (local admin path) instead of /usr/lib (vendor-managed path) to avoid being overwritten by system updates - Replace awk seat-based user detection with loginctl show-session loop that checks Active/State/Remote per session, targeting only local active sessions - Use bash instead of source to invoke nvidia-suspend-hook.sh, making the privileged side effects explicit and isolated in a subshell
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The pre handler kills hyprlock to release the DRM context, but without a post handler, if hypridle's after_sleep_cmd doesn't fire (e.g. hypridle crashed), the session resumes with no visual lock screen. Add a post handler that calls loginctl lock-sessions after a 5s delay (matching the unmount-fuse pattern to let user sessions thaw first). If hypridle is running, it handles the signal via lock_cmd as normal; omarchy-lock-screen's pidof guard prevents a double launch if after_sleep_cmd already ran.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @dhh, this is my first contribution and I'm still not sure how far I should follow the copilot suggestions in order to have this fix in a good shape. What's your opinion around that? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hyprlock holds an active DRM/GBM context on the GPU that prevents the nvidia_drm suspend callback from checkpointing GPU state cleanly. The kernel hangs at PM: suspend entry (deep) with no recovery possible.
Add a system-sleep hook (nvidia-hyprlock) that kills hyprlock just before the kernel DRM checkpoint fires — after hypridle's inhibit_sleep window, so the session is already locked. Also update after_sleep_cmd to relaunch hyprlock before enabling the display on resume, preventing a window where the unlocked desktop is briefly visible.
Fixes #5277