Help testing Nvidia drivers with Kernel 6.12

This is a bit of a longer story, I’ll try my best to keep it short:

Whenever the system goes to sleep/hibernation and wakes up, NVIDIA hooks those events using /usr/lib/systemd/system-sleep/nvidia and directs them to their script /usr/bin/nvidia-sleep.sh.

When entering sleep/hibernation, the script is called with argument suspend. It will then switch to a certain virtual terminal and issue a suspend request to the driver.

When waking up, the script is called with argument resume. It will then issue a resume request to the driver and switch back to the virtual terminal that was active before entering sleep/hibernation (i.e. usually the vt running X11/Wayland).

Now, on my system, I noticed that said script never gets called when entering sleep/hibernation. Services /usr/lib/systemd/system/nvidia-*.service should do that, but they don’t on my system. I’m not overly familiar with systemd, maybe those services just need some additional configuration?

Anyway, to quickly fix this, I simply patched the hook to perform both operations:

#!/bin/sh
case "$1" in
    pre)
        /usr/bin/nvidia-sleep.sh "suspend"
        ;;
    post)
        /usr/bin/nvidia-sleep.sh "resume"
        ;;
esac