Fixing EndeavourOS sleep glitches with NVIDIA

I was having trouble with resuming from sleep when using EndeavorOS. I would get graphical glitches or sometimes just a black screen I couldn't resume from. Terminals worked OK. I came across this Reddit post by Tuxy666

which describes the solution as follows:

sudo systemctl enable nvidia-suspend.service

sudo systemctl enable nvidia-hibernate.service

sudo systemctl enable nvidia-resume.service

cd /lib/modeprobe.d

sudo nano systemd.conf

Add following line at the end of the file:

options nvidia NVreg_PreserveVideoMemoryAllocations=1

CTRL-X and save file out.

Then run:

sudo reinstall-kernels

and reboot