This solution aims to resolve the issue where Hyprland crashes when waking up on systems with an NVIDIA GPU
Hyprland is attempting to communicate with the NVIDIA driver after it has already entered suspend mode, so it cannot respond. Linux tries to freeze the task but fails because Hyprland is waiting for a response from the driver and cannot be frozen.
The solution is to manually suspend Hyprland using the "STOP" signal before the NVIDIA driver goes into suspend mode. Then use the "CONT" signal upon resuming.
The solution involves the following steps:
-
Create a script
suspend-hyprland.sh
to suspend and resume Hyprland. -
Create systemd services
hyprland-suspend.service
andhyprland-resume.service
to manage the suspension and resumption of Hyprland. -
Reload the systemd daemon and enable the newly created services.
Create a script suspend-hyprland.sh
:
#!/bin/bash
case "$1" in
suspend)
killall -STOP Hyprland
;;
resume)
killall -CONT Hyprland
;;
esac
Create a systemd service hyprland-suspend.service
:
[Unit]
Description=Suspend hyprland
Before=systemd-suspend.service
Before=systemd-hibernate.service
Before=nvidia-suspend.service
Before=nvidia-hibernate.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/suspend-hyprland.sh suspend
[Install]
WantedBy=systemd-suspend.service
WantedBy=systemd-hibernate.service
Create a systemd service hyprland-resume.service
:
[Unit]
Description=Resume hyprland
After=systemd-suspend.service
After=systemd-hibernate.service
After=nvidia-resume.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/suspend-hyprland.sh resume
[Install]
WantedBy=systemd-suspend.service
WantedBy=systemd-hibernate.service
sudo systemctl daemon-reload
sudo systemctl enable hyprland-suspend.service
sudo systemctl enable hyprland-resume.service