I am trying to have my laptop (Dell Precision 5530) hibernate when I close the lid, however hibernate hangs and crashes xorg. I figured out I can suspend manually (successfully) by running:
sudo /bin/nvidia-sleep.sh hibernate && sudo loginctl hibernate
Running just
sudo loginctl hibernate
by itself hangs on a black screen and crashes xorg when I finally reboot.
To enable hibernate I edited /etc/default/grub to:
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet resume=/dev/nvme0n1p2 nvidia"
and update-grub
sudo grub-mkconfig -o /boot/grub/grub.cfg
I also added resume to mkinitcpio hooks:
HOOKS=(base udev autodetect modconf block filesystems keyboard resume fsck)
sudo mkinitcpio -P
I modified the hook script in /lib/elogind/system-sleep/nvidia to and made sure it was marked executable.
#!/bin/sh
case "$1" in
pre)
/usr/bin/nvidia-sleep.sh "hibernate"
;;
post)
/usr/bin/nvidia-sleep.sh "resume"
;;
esac
ls -laF /lib/elogind/system-sleep/
drwxr-xr-x 2 root root 4096 Feb 2 10:59 ./
drwxr-xr-x 6 root root 4096 Feb 1 21:48 ../
-rwxr-xr-x 1 root root 140 Jan 19 11:15 49-tlp-sleep*
-rw-r--r-- 1 root root 0 Jun 18 2021 .keep_dir
-rwxr-xr-x 1 root root 212 Feb 2 10:24 nvidia*
I also modified /etc/elogind/logind.conf changing the HandleLidSwitch to change the lid behvior to hibernate:
HandleLidSwitch=hibernate
HandleLidSwitchExternalPower=hibernate
HandleLidSwitchDocked=hibernate
After modifying the hook script I expected similar behavior running
sudo loginctl hibernate
as running
sudo /bin/nvidia-sleep.sh hibernate && sudo loginctl hibernate
however the behavior remains the same as if I ran
sudo loginctl hibernate
before the modifications (hangs & crashes xorg).
I am running linux-lts and using nvidia-dkms drivers with runit as the init system.
uname -r
5.15.16-1-lts
Thanks in advance for any help.