Nvidia Prime stops working after update fix

This is not the first time this happened, but after an update that includes nvidia drivers my secondary monitor is not active anymore and prime-run glxinfo returns BadValueError with 152 (GlCreateNewContext failed) or something similar… I fixed it now so I don’t have the exact error anymore.

What always fixes the problem is this guide:

[HowTo] Set up PRIME (output offload) with NVIDIA proprietary driver

(Sorry I can’t post links yet, maybe someone with the privileges can do the favor).

And it would probably be best if these steps got integrated into the setup of the mhwd configuration of video-hybrid-intel-nvidia-prime (The config I am using) and maybe others aswell.

Basically it’s just a change to the blacklisting in /etc/modprobe.d and a different Xorg configuration. Then we should prevent the display manager’s configuration from being overwritten, because I also have to re-set the lightdm display-setup-script variable in /etc/lightdm/lightdm.conf to my xrandr configuration script after each update.