Fix nvidia sleep script prevents lockscreen
On a debian bookworm where both, nvidia drivers and a lockscreen application that prevents changing virtual terminals (VT) when in locked state - such as sxlock - are installed, the system fails to enter suspend state with a locked screen. Instead, the screen is locked, and only after unlocking it, the system goes into suspend mode and once resuming, the system is in an unlocked state.
The reason for this is the /usr/bin/nvidia-sleep.sh that is installed by the nvidia-suspend-common package and invoked by the nvidia-suspend.service. The dependecies for entering suspend state are
| |
The /usr/bin/nvidia-sleep.sh is invoked after the screen was locked. However the script contains a snippet that stores the currently active virtual terminal and then switches to VT 63 when invoked before going to suspend and vice versa when invoked after resuming. The call to chvt is the part that causes the script to wait for the screen to get unlocked so switching of VTs becomes possible again.
To fix this comment out the chvt calls in /usr/bin/nvidia-sleep.sh.