Skip to content

Fix NVIDIA suspend hard-freeze when hyprlock is active#5283

Open
jpmsantana wants to merge 13 commits intobasecamp:devfrom
jpmsantana:fix-nvidia-suspend-hyprlock
Open

Fix NVIDIA suspend hard-freeze when hyprlock is active#5283
jpmsantana wants to merge 13 commits intobasecamp:devfrom
jpmsantana:fix-nvidia-suspend-hyprlock

Conversation

@jpmsantana
Copy link
Copy Markdown

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

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
Copilot AI review requested due to automatic review settings April 12, 2026 02:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 systemd system-sleep hook that kills hyprlock right before suspend on NVIDIA systems.
  • Update Hypridle’s after_sleep_cmd to 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.

Comment thread config/hypr/hypridle.conf Outdated
Comment thread migrations/1776042000.sh Outdated
Comment thread default/systemd/system-sleep/nvidia-hyprlock Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 12, 2026 02:46
jpmsantana and others added 2 commits April 11, 2026 23:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread migrations/1776042000.sh
Comment thread install/config/hardware/nvidia.sh Outdated
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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread default/systemd/system-sleep/nvidia-hyprlock Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 12, 2026 02:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread install/config/hardware/nvidia-suspend-hook.sh Outdated
Comment thread default/systemd/system-sleep/nvidia-hyprlock Outdated
Comment thread install/config/hardware/nvidia.sh Outdated
…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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread default/systemd/system-sleep/nvidia-hyprlock Outdated
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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread default/systemd/system-sleep/nvidia-hyprlock Outdated
Comment thread default/systemd/system-sleep/nvidia-hyprlock
@jpmsantana
Copy link
Copy Markdown
Author

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?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread migrations/1776042000.sh Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 13, 2026 01:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread install/config/hardware/nvidia-suspend-hook.sh Outdated
Comment thread migrations/1776042000.sh Outdated
Comment thread default/systemd/system-sleep/nvidia-hyprlock Outdated
Comment thread default/systemd/system-sleep/nvidia-hyprlock Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread install/config/hardware/nvidia-suspend-hook.sh Outdated
Comment thread default/systemd/system-sleep/nvidia-hyprlock Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread migrations/1776042000.sh Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 13, 2026 02:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

System hard-freeze on suspend with hyprlock active — no resume, requires hard reboot

2 participants