[Main]
Type = oneshot
RequiredBy = ( sddm )
TimeoutStop = 5000
[Start]
Execute = ( true )
[Stop]
Execute=( modprobe -r nvidia nvidia_drm nvidia_modeset nvidia_uvm )
At start time (a no-op here) it will be launched before sddm, at stop time it will be stopped after sddm.
Anyway, this is an hack, it doesn't solve the bug from Nvidia. This is not depending of the init system(you will have the same trouble with systemd). Anything else holding /dev/nvidia* will make the removal fail with EBUSY and you're back to the hang. If you run CUDA services, nvidia-persistenced, ollama, etc., they need to be in that RequiredBy too.